Documentation ¶
Index ¶
- Constants
- func Close()
- func Critical(skip int, format string, v ...interface{})
- func Debug(format string, v ...interface{})
- func DelLogger(mode string) error
- func DiscardXORMLogger()
- func Error(skip int, format string, v ...interface{})
- func Fatal(skip int, format string, v ...interface{})
- func Info(format string, v ...interface{})
- func NewGitLogger(logPath string)
- func NewLogger(bufLen int64, mode, config string)
- func NewXORMLogger(bufferlen int64, mode, config string)
- func Register(name string, log loggerType)
- func Trace(format string, v ...interface{})
- func Warn(format string, v ...interface{})
- type Brush
- type ConnWriter
- type ConsoleWriter
- type FileLogWriter
- type Logger
- func (l *Logger) Close()
- func (l *Logger) Critical(skip int, format string, v ...interface{})
- func (l *Logger) Debug(format string, v ...interface{})
- func (l *Logger) DelLogger(adapter string) error
- func (l *Logger) Error(skip int, format string, v ...interface{})
- func (l *Logger) Fatal(skip int, format string, v ...interface{})
- func (l *Logger) Flush()
- func (l *Logger) Info(format string, v ...interface{})
- func (l *Logger) SetLogger(adapter string, config string) error
- func (l *Logger) StartLogger()
- func (l *Logger) Trace(format string, v ...interface{})
- func (l *Logger) Warn(format string, v ...interface{})
- type LoggerAsWriter
- type LoggerInterface
- type MuxWriter
- type SMTPWriter
- type XORMLogBridge
- func (l *XORMLogBridge) Debug(v ...interface{})
- func (l *XORMLogBridge) Debugf(format string, v ...interface{})
- func (l *XORMLogBridge) Error(v ...interface{})
- func (l *XORMLogBridge) Errorf(format string, v ...interface{})
- func (l *XORMLogBridge) Info(v ...interface{})
- func (l *XORMLogBridge) Infof(format string, v ...interface{})
- func (l *XORMLogBridge) IsShowSQL() bool
- func (l *XORMLogBridge) Level() core.LogLevel
- func (l *XORMLogBridge) SetLevel(level core.LogLevel)
- func (l *XORMLogBridge) ShowSQL(show ...bool)
- func (l *XORMLogBridge) Warn(v ...interface{})
- func (l *XORMLogBridge) Warnf(format string, v ...interface{})
Constants ¶
const ( TRACE = iota DEBUG INFO WARN ERROR CRITICAL FATAL )
log levels
Variables ¶
This section is empty.
Functions ¶
func DiscardXORMLogger ¶ added in v1.1.0
func DiscardXORMLogger()
DiscardXORMLogger inits a blank logger for xorm
func NewGitLogger ¶
func NewGitLogger(logPath string)
NewGitLogger create a logger for git FIXME: use same log level as other loggers.
func NewXORMLogger ¶ added in v1.1.0
NewXORMLogger generate logger for xorm FIXME: configable
Types ¶
type ConnWriter ¶
type ConnWriter struct { ReconnectOnMsg bool `json:"reconnectOnMsg"` Reconnect bool `json:"reconnect"` Net string `json:"net"` Addr string `json:"addr"` Level int `json:"level"` // contains filtered or unexported fields }
ConnWriter implements LoggerInterface. it writes messages in keep-live tcp connection.
func (*ConnWriter) Destroy ¶
func (cw *ConnWriter) Destroy()
Destroy destroy connection writer and close tcp listener.
func (*ConnWriter) Init ¶
func (cw *ConnWriter) Init(jsonconfig string) error
Init inits connection writer with json config. json config only need key "level".
type ConsoleWriter ¶
type ConsoleWriter struct { Level int `json:"level"` // contains filtered or unexported fields }
ConsoleWriter implements LoggerInterface and writes messages to terminal.
func (*ConsoleWriter) Init ¶
func (cw *ConsoleWriter) Init(config string) error
Init inits connection writer with json config. json config only need key "level".
type FileLogWriter ¶
type FileLogWriter struct { *log.Logger // The opened file Filename string `json:"filename"` // Rotate at size Maxsize int `json:"maxsize"` // Rotate daily Daily bool `json:"daily"` Maxdays int64 `json:"maxdays"` Rotate bool `json:"rotate"` Level int `json:"level"` // contains filtered or unexported fields }
FileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.
func (*FileLogWriter) Destroy ¶
func (w *FileLogWriter) Destroy()
Destroy destroy file logger, close file writer.
func (*FileLogWriter) DoRotate ¶
func (w *FileLogWriter) DoRotate() error
DoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2
func (*FileLogWriter) Flush ¶
func (w *FileLogWriter) Flush()
Flush flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.
func (*FileLogWriter) Init ¶
func (w *FileLogWriter) Init(config string) error
Init file logger with json config. config like:
{ "filename":"log/gogs.log", "maxsize":1<<30, "daily":true, "maxdays":15, "rotate":true }
func (*FileLogWriter) StartLogger ¶
func (w *FileLogWriter) StartLogger() error
StartLogger start file logger. create log file and set to locker-inside file writer.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is default logger in beego application. it can contain several providers and log message into all providers.
var ( // GitLogger logger for git GitLogger *Logger )
func (*Logger) Close ¶
func (l *Logger) Close()
Close closes logger, flush all chan data and destroy all adapter instances.
type LoggerAsWriter ¶ added in v1.8.1
type LoggerAsWriter struct {
// contains filtered or unexported fields
}
LoggerAsWriter is a io.Writer shim around the gitea log
func NewLoggerAsWriter ¶ added in v1.8.1
func NewLoggerAsWriter(level string) *LoggerAsWriter
NewLoggerAsWriter creates a Writer representation of the logger with setable log level
func (*LoggerAsWriter) Log ¶ added in v1.8.1
func (l *LoggerAsWriter) Log(msg string)
Log takes a given string and logs it at the set log-level
type LoggerInterface ¶
type LoggerInterface interface { Init(config string) error WriteMsg(msg string, skip, level int) error Destroy() Flush() }
LoggerInterface represents behaviors of a logger provider.
func NewConn ¶
func NewConn() LoggerInterface
NewConn creates new ConnWrite returning as LoggerInterface.
func NewConsole ¶
func NewConsole() LoggerInterface
NewConsole create ConsoleWriter returning as LoggerInterface.
func NewFileWriter ¶
func NewFileWriter() LoggerInterface
NewFileWriter create a FileLogWriter returning as LoggerInterface.
func NewSMTPWriter ¶ added in v1.0.0
func NewSMTPWriter() LoggerInterface
NewSMTPWriter creates smtp writer.
type SMTPWriter ¶ added in v1.0.0
type SMTPWriter struct { Username string `json:"Username"` Password string `json:"password"` Host string `json:"Host"` Subject string `json:"subject"` RecipientAddresses []string `json:"sendTos"` Level int `json:"level"` }
SMTPWriter implements LoggerInterface and is used to send emails via given SMTP-server.
func (*SMTPWriter) Destroy ¶ added in v1.0.0
func (sw *SMTPWriter) Destroy()
Destroy when writer is destroy
func (*SMTPWriter) Flush ¶ added in v1.0.0
func (sw *SMTPWriter) Flush()
Flush when log should be flushed
func (*SMTPWriter) Init ¶ added in v1.0.0
func (sw *SMTPWriter) Init(jsonconfig string) error
Init smtp writer with json config. config like:
{ "Username":"example@gmail.com", "password:"password", "host":"smtp.gmail.com:465", "subject":"email title", "sendTos":["email1","email2"], "level":LevelError }
type XORMLogBridge ¶ added in v1.1.0
type XORMLogBridge struct {
// contains filtered or unexported fields
}
XORMLogBridge a logger bridge from Logger to xorm
var ( // XORMLogger the logger for xorm XORMLogger *XORMLogBridge )
func (*XORMLogBridge) Debug ¶ added in v1.1.0
func (l *XORMLogBridge) Debug(v ...interface{})
Debug show debug log
func (*XORMLogBridge) Debugf ¶ added in v1.1.0
func (l *XORMLogBridge) Debugf(format string, v ...interface{})
Debugf show debug log
func (*XORMLogBridge) Error ¶ added in v1.1.0
func (l *XORMLogBridge) Error(v ...interface{})
Error show error log
func (*XORMLogBridge) Errorf ¶ added in v1.1.0
func (l *XORMLogBridge) Errorf(format string, v ...interface{})
Errorf show error log
func (*XORMLogBridge) Info ¶ added in v1.1.0
func (l *XORMLogBridge) Info(v ...interface{})
Info show information level log
func (*XORMLogBridge) Infof ¶ added in v1.1.0
func (l *XORMLogBridge) Infof(format string, v ...interface{})
Infof show information level log
func (*XORMLogBridge) IsShowSQL ¶ added in v1.1.0
func (l *XORMLogBridge) IsShowSQL() bool
IsShowSQL if record SQL
func (*XORMLogBridge) Level ¶ added in v1.1.0
func (l *XORMLogBridge) Level() core.LogLevel
Level get logger level
func (*XORMLogBridge) SetLevel ¶ added in v1.1.0
func (l *XORMLogBridge) SetLevel(level core.LogLevel)
SetLevel set logger level
func (*XORMLogBridge) ShowSQL ¶ added in v1.1.0
func (l *XORMLogBridge) ShowSQL(show ...bool)
ShowSQL set if record SQL
func (*XORMLogBridge) Warn ¶ added in v1.1.0
func (l *XORMLogBridge) Warn(v ...interface{})
Warn show warning log
func (*XORMLogBridge) Warnf ¶ added in v1.1.0
func (l *XORMLogBridge) Warnf(format string, v ...interface{})
Warnf show warnning log