Documentation ¶
Index ¶
- Constants
- Variables
- func Close()
- func Debug(module string, method string, msg string, reqId uint32, args ...interface{})
- func Error(module string, method string, msg string, reqId uint32, args ...interface{})
- func Fatal(module string, method string, msg string, reqId uint32, args ...interface{})
- func GetLevel() int
- func Info(module string, method string, msg string, reqId uint32, args ...interface{})
- func OutputSql(state string, format string, v ...interface{})
- func SetLevel(level int)
- func Trace(module string, method string, msg string, reqId uint32, args ...interface{})
- func Warn(module string, method string, msg string, reqId uint32, args ...interface{})
- type FileHandler
- type Handler
- type Logger
- type NullHandler
- type RotatingFileHandler
- type StreamHandler
- type TimeRotatingFileHandler
Constants ¶
const ( WhenSecond = iota WhenMinute WhenHour WhenDay )
const ( LevelTrace = iota LevelDebug LevelInfo LevelWarn LevelError LevelFatal )
log level, from low to high, more high means more serious
const ( Ltime = 1 << iota //time format "2006/01/02 15:04:05" Lfile //file.go:123 Llevel //[Trace|Debug|Info...] )
const ( LogSqlOn = "on" LogSqlOff = "off" TimeFormat = "2006/01/02 15:04:05" )
Variables ¶
var GlobalSqlLogger = GlobalSysLogger
var GlobalSysLogger = StdLogger()
全局变量
var LevelName = [6]string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"}
Functions ¶
Types ¶
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler writes log to a file.
func NewFileHandler ¶
func NewFileHandler(fileName string, flag int) (*FileHandler, error)
func (*FileHandler) Close ¶
func (h *FileHandler) Close() error
type Logger ¶
func NewDefault ¶
new a default logger with specified handler and flag: Ltime|Lfile|Llevel
func (*Logger) Output ¶
a low interface, maybe you can use it for your special log format but it may be not exported later......
type NullHandler ¶
type NullHandler struct { }
NullHandler does nothing, it discards anything.
func NewNullHandler ¶
func NewNullHandler() (*NullHandler, error)
func (*NullHandler) Close ¶
func (h *NullHandler) Close() error
type RotatingFileHandler ¶
type RotatingFileHandler struct {
// contains filtered or unexported fields
}
RotatingFileHandler writes log a file, if file size exceeds maxBytes, it will backup current file and open a new one.
max backup file number is set by backupCount, it will delete oldest if backups too many.
func NewRotatingFileHandler ¶
func NewRotatingFileHandler(fileName string, maxBytes int, backupCount int) (*RotatingFileHandler, error)
func (*RotatingFileHandler) Close ¶
func (h *RotatingFileHandler) Close() error
type StreamHandler ¶
type StreamHandler struct {
// contains filtered or unexported fields
}
StreamHandler writes logs to a specified io Writer, maybe stdout, stderr, etc...
func NewStreamHandler ¶
func NewStreamHandler(w io.Writer) (*StreamHandler, error)
func (*StreamHandler) Close ¶
func (h *StreamHandler) Close() error
type TimeRotatingFileHandler ¶
type TimeRotatingFileHandler struct {
// contains filtered or unexported fields
}
TimeRotatingFileHandler writes log to a file, it will backup current and open a new one, with a period time you sepecified.
refer: http://docs.python.org/2/library/logging.handlers.html. same like python TimedRotatingFileHandler.
func NewTimeRotatingFileHandler ¶
func NewTimeRotatingFileHandler(baseName string, when int8, interval int) (*TimeRotatingFileHandler, error)
func (*TimeRotatingFileHandler) Close ¶
func (h *TimeRotatingFileHandler) Close() error