Documentation
¶
Index ¶
- Constants
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Register(name string, log loggerType)
- func SetLevel(l int)
- func SetLogFile(logFile string, level int, isRotateDaily, drawColor bool, rotateMaxDays int)
- func SetLogFuncCall(b bool)
- func Trace(v ...interface{})
- func Tracef(format string, v ...interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Brush
- type ConsoleWriter
- type FileLogWriter
- type Logger
- func (bl *Logger) Async() *Logger
- func (bl *Logger) Close()
- func (bl *Logger) Debug(v ...interface{})
- func (bl *Logger) Debugf(format string, v ...interface{})
- func (bl *Logger) DelLogger(adaptername string) error
- func (bl *Logger) EnableFuncCallDepth(b bool)
- func (bl *Logger) Error(v ...interface{})
- func (bl *Logger) Errorf(format string, v ...interface{})
- func (bl *Logger) Fatal(v ...interface{})
- func (bl *Logger) Fatalf(format string, v ...interface{})
- func (bl *Logger) Flush()
- func (bl *Logger) GetLogFuncCallDepth() int
- func (bl *Logger) Info(v ...interface{})
- func (bl *Logger) Infof(format string, v ...interface{})
- func (bl *Logger) SetLevel(l int)
- func (bl *Logger) SetLogFile(logFile string, level int, isRotateDaily, drawColor bool, rotateMaxDays int) error
- func (bl *Logger) SetLogFuncCall(b bool)
- func (bl *Logger) SetLogFuncCallDepth(d int)
- func (bl *Logger) SetLogFuncCallWithDepth(b bool, depth int)
- func (bl *Logger) SetLogger(adaptername string, config string) error
- func (bl *Logger) Trace(v ...interface{})
- func (bl *Logger) Tracef(format string, v ...interface{})
- func (bl *Logger) Warn(v ...interface{})
- func (bl *Logger) Warnf(format string, v ...interface{})
- type LoggerInterface
- type MuxWriter
Constants ¶
const ( LevelError = iota LevelWarn LevelInfo LevelDebug LevelTrace )
RFC5424 log message levels.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(name string, log loggerType)
Register makes a log provide available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.
func SetLevel ¶
func SetLevel(l int)
SetLogLevel sets the global log level used by the simple logger.
func SetLogFile ¶
func SetLogFuncCall ¶
func SetLogFuncCall(b bool)
Types ¶
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 (c *ConsoleWriter) Init(jsonconfig string) error
init console logger. jsonconfig like '{"level":LevelTrace}'.
type FileLogWriter ¶
type FileLogWriter struct { *log.Logger // The opened file Filename string `json:"filename"` Maxlines int `json:"maxlines"` // 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"` DrawColor bool `json:"drawcolor"` // 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 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 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(jsonconfig string) error
Init file logger with json config. jsonconfig like:
{ "filename":"logs/beego.log", "maxlines":10000, "maxsize":1<<30, "daily":true, "maxdays":15, "rotate":true }
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.
func GetDefaultLogger ¶
func GetDefaultLogger() *Logger
func NewConsoleLogger ¶
func NewLogger ¶
NewLogger returns a new Logger. channellen means the number of messages in chan. if the buffering chan is full, logger adapters write to file or other way.
func (*Logger) Close ¶
func (bl *Logger) Close()
close logger, flush all chan data and destroy all adapters in Logger.
func (*Logger) EnableFuncCallDepth ¶
enable log funcCallDepth
func (*Logger) GetLogFuncCallDepth ¶
get log funcCallDepth for wrapper
func (*Logger) SetLevel ¶
Set log message level.
If message level (such as LevelDebug) is higher than logger level (such as LevelWarning), log providers will not even be sent the message.
func (*Logger) SetLogFile ¶
func (*Logger) SetLogFuncCall ¶
func (*Logger) SetLogFuncCallDepth ¶
set log funcCallDepth
func (*Logger) SetLogFuncCallWithDepth ¶
func (*Logger) SetLogger ¶
SetLogger provides a given logger adapter into Logger with config string. config need to be correct JSON as string: {"interval":360}.
type LoggerInterface ¶
type LoggerInterface interface { Init(config string) error WriteMsg(msg string, level int) error Destroy() Flush() }
LoggerInterface defines the behavior of a log provider.
func NewConsole ¶
func NewConsole() LoggerInterface
create ConsoleWriter returning as LoggerInterface.
func NewFileWriter ¶
func NewFileWriter() LoggerInterface
create a FileLogWriter returning as LoggerInterface.