Documentation ¶
Index ¶
- Constants
- Variables
- func Critical(format string, a ...interface{})
- func Debug(format string, a ...interface{})
- func Error(format string, a ...interface{})
- func Info(format string, a ...interface{})
- func LogIsStart() bool
- func NewLogger()
- func Notice(format string, a ...interface{})
- func Warning(format string, a ...interface{})
- type LogLevel
- type Logger
- func (l *Logger) Critical(format string, a ...interface{})
- func (l *Logger) Debug(format string, a ...interface{})
- func (l *Logger) Error(format string, a ...interface{})
- func (l *Logger) Info(format string, a ...interface{})
- func (l *Logger) LogFile(fileName string) *Logger
- func (l *Logger) Notice(format string, a ...interface{})
- func (l *Logger) Warning(format string, a ...interface{})
- type Message
- type Record
- type StreamMessageHandler
Constants ¶
View Source
const ( ColorRed // red ColorGreen // green ColorYellow // yellow ColorBlue // blue ColorMagenta // magenta ColorWhite // white )
View Source
const ( TextType = "text" JsonType = "json" )
LogType
View Source
const ( NOTSET = iota DEBUG = LogLevel(10 * iota) // DEBUG = 10 INFO = LogLevel(10 * iota) // INFO = 20 NOTICE = LogLevel(10 * iota) // INFO = 30 WARNING = LogLevel(10 * iota) // WARNING = 40 ERROR = LogLevel(10 * iota) // ERROR = 50 CRITICAL = LogLevel(10 * iota) // CRITICAL = 60 )
MessageLevel
View Source
const LevelColorSetClear = "\033[0m"
View Source
const MaxWarnLogFileCount = 20
Variables ¶
View Source
var LevelColorFlag = []string{ DEBUG: colorSet(ColorWhite, 0), INFO: colorSet(ColorGreen, 0), NOTICE: colorSet(ColorBlue, 0), WARNING: colorSet(ColorYellow, 0), ERROR: colorSet(ColorRed, 1), CRITICAL: colorSet(ColorMagenta, 1), }
LevelColorFlag, MessageLevel color flag.
Functions ¶
Types ¶
type Logger ¶
type Logger struct { Level LogLevel Record *Record Format *Message StreamHandler *StreamMessageHandler SyncInterval int }
Logger main logger struct
type Message ¶
Message log message struct
func (*Message) GetMessage ¶
GetMessage, return formatted message string for output.
type Record ¶
type Record struct { Level LogLevel `json:"-"` LevelString string `json:"level"` Message string `json:"message"` Pid int `json:"-"` Program string `json:"program"` Time string `json:"time"` FuncName string `json:"func_name"` Path string `json:"path"` FileName string `json:"file_name"` Line int `json:"line"` Color string `json:"-"` ColorClear string `json:"-"` }
Record
func GetMessageRecord ¶
GetMessageRecord, make a record and return it's reference.
type StreamMessageHandler ¶
type StreamMessageHandler struct { LogDir string LogFileName string LogExt string LogBuffer bytes.Buffer }
StreamMessageHandler
func (*StreamMessageHandler) SyncLog ¶
func (handler *StreamMessageHandler) SyncLog()
SyncLog interval sync log stream buffer
func (*StreamMessageHandler) Write ¶
func (handler *StreamMessageHandler) Write(message []byte)
Write write log to buffer
Click to show internal directories.
Click to hide internal directories.