Documentation ¶
Index ¶
- Constants
- Variables
- func CloseProducer()
- func Critical(format string, a ...interface{})
- func Criticalw(message string, kv ...interface{})
- func Debug(format string, a ...interface{})
- func Debugw(message string, kv ...interface{})
- func Error(format string, a ...interface{})
- func Errorw(message string, kv ...interface{})
- func Info(format string, a ...interface{})
- func Infow(message string, kv ...interface{})
- func LogCloseAll()
- func LogIsStart() bool
- func NewLogger()
- func Notice(format string, a ...interface{})
- func Noticew(message string, kv ...interface{})
- func Warning(format string, a ...interface{})
- func Warningw(message string, kv ...interface{})
- type Field
- type LogLevel
- type Logger
- func (l *Logger) Critical(format string, a ...interface{})
- func (l *Logger) Criticalw(message string, kv ...interface{})
- func (l *Logger) Debug(format string, a ...interface{})
- func (l *Logger) Debugw(message string, kv ...interface{})
- func (l *Logger) Error(format string, a ...interface{})
- func (l *Logger) Errorw(message string, kv ...interface{})
- func (l *Logger) Info(format string, a ...interface{})
- func (l *Logger) Infow(message string, kv ...interface{})
- func (l *Logger) LogDeferClose()
- func (l *Logger) LogFile(fileName string) *Logger
- func (l *Logger) Notice(format string, a ...interface{})
- func (l *Logger) Noticew(message string, kv ...interface{})
- func (l *Logger) Warning(format string, a ...interface{})
- func (l *Logger) Warningw(message string, kv ...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
View Source
const TraceName = "X-OR-TRACE-ID"
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 ¶
func CloseProducer ¶ added in v0.5.1
func CloseProducer()
func Criticalw ¶ added in v0.2.8
func Criticalw(message string, kv ...interface{})
Criticalw, record CRITICAL message with kv format.
func Debugw ¶ added in v0.2.8
func Debugw(message string, kv ...interface{})
Debugw, record DEBUG message with kv format.
func Errorw ¶ added in v0.2.8
func Errorw(message string, kv ...interface{})
Errorw, record ERROR message with kv format.
func Infow ¶ added in v0.2.8
func Infow(message string, kv ...interface{})
Infow, record INFO message with kv format.
func LogCloseAll ¶ added in v0.2.8
func LogCloseAll()
Types ¶
type Logger ¶
type Logger struct { Level LogLevel Record *Record Format *Message StreamHandler *StreamMessageHandler SyncInterval int // contains filtered or unexported fields }
Logger main logger struct
func (*Logger) LogDeferClose ¶ added in v0.2.8
func (l *Logger) LogDeferClose()
LogDeferClose close handler
type Message ¶
Message log message struct
func (*Message) GetFieldKvJson ¶ added in v0.2.8
GetFieldKvJson
func (*Message) GetMessage ¶
GetMessage, return formatted message string for output.
type Record ¶
type Record struct { Level LogLevel `json:"-"` LevelString string `json:"level"` LogFile string `json:"log_file"` Message string `json:"message"` TraceId string `json:"or_trace_id,omitempty"` KvField []Field `json:"-"` KvJson string `json:"-"` Pid int `json:"-"` Program string `json:"program"` Time string `json:"time"` FuncName string `json:"func_name"` Path string `json:"path"` FileName string `json:"file"` Line int `json:"line"` Color string `json:"-"` ColorClear string `json:"-"` }
Record
type StreamMessageHandler ¶
type StreamMessageHandler struct { LogDir string LogFileName string LogExt string LogFilePath string LogBuffer *bytes.Buffer BufferLine uint64 LogFileHandler *os.File // contains filtered or unexported fields }
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.