Documentation
¶
Overview ¶
Package midlog is a log library with middle ware,you can kind log from midlog to different files.
Index ¶
- Constants
- func CommonFormatField(val *interface{})
- func CommonFormatFields(vals []interface{})
- func GetIsRecordCaller() bool
- func LevelName(level LogLevel) string
- func SetCustomStdWriter(exp string)
- func SetIsRecordCaller(val bool)
- func SetLevelPower(level LogLevel)
- func SetWriter(newWriter LogWriter)
- type Caller
- type ExtMap
- type LogFormater
- type LogLevel
- type LogWriter
- type Midlog
Constants ¶
const FormatDefault = "$time_local $module $level $ext $msg"
FormatDefault is a recommend fields log format expression
const FormatJsonFull = "json($time_local,$module,$level,$file,$line,$ext,$msg)"
FormatJsonFull is a full fields json log format expression
const FormatTextFull = "$time_local $module $level $file:$line $ext $msg"
FormatTextFull is a full fields text log format expression
const LocalTimeFormat = "2006-01-02 15:04:05"
LocalTimeFormat is a time format expression with 2006-01-02 15:04:05
Variables ¶
This section is empty.
Functions ¶
func CommonFormatField ¶ added in v0.2.0
func CommonFormatField(val *interface{})
CommonFormatField is a common format parameter with write log methods
func CommonFormatFields ¶ added in v0.2.0
func CommonFormatFields(vals []interface{})
CommonFormatFields is a common format parameters with write log methods
func GetIsRecordCaller ¶ added in v0.2.0
func GetIsRecordCaller() bool
GetIsRecordCaller is a function with get configuration with isRecordCaller
func SetCustomStdWriter ¶ added in v0.3.1
func SetCustomStdWriter(exp string)
SetCustomStdWriter set Writer to midlog with expression
func SetIsRecordCaller ¶ added in v0.2.0
func SetIsRecordCaller(val bool)
SetIsRecordCaller is a function with set configuration with isRecordCaller
func SetLevelPower ¶ added in v0.2.0
func SetLevelPower(level LogLevel)
SetLevelPower is set powerLevel to filter log
Types ¶
type ExtMap ¶ added in v0.2.0
type ExtMap map[string]interface{}
ExtMap is a map with map[string]interface{}
type LogFormater ¶ added in v0.2.0
type LogFormater interface { //init with expression Init(exp string) error //Format log info with byte array Format(module string, level LogLevel, caller *Caller, ext ExtMap, msg ...interface{}) ([]byte, error) }
LogFormater is a interface with log format
func NewFormater ¶
func NewFormater(exp string) (LogFormater, error)
NewFormater is a funnction to make a LogFormat object with expression
type LogLevel ¶ added in v0.2.0
type LogLevel int32
LogLevel is type with int32
const ( //LevelTrace is a const enums with trace log level LevelTrace LogLevel = iota + 1 //LevelDebug is a const enums with debug log level LevelDebug //LevelInfo is a const enums with information log level LevelInfo //LevelRootLog is a const enums with native golang log level LevelRootLog //LevelWarn is a const enums with warn log level LevelWarn LogLevel = 101 //LevelError1 is a const enums with error log level 1 LevelError1 LogLevel = 201 //LevelError2 is a const enums with error log level 2 LevelError2 LogLevel = 202 //LevelError3 is a const enums with error log level 3 LevelError3 LogLevel = 203 )
func GetLevelPower ¶ added in v0.2.0
func GetLevelPower() LogLevel
type LogWriter ¶
type LogWriter interface { //Write is a method, invoked when write log Write(logger Midlog, level LogLevel, caller *Caller, pams ...interface{}) }
LogWriter is a interface with write log
func GetDefaultWriter ¶ added in v0.2.0
func GetDefaultWriter() LogWriter
GetDefaultWriter is get default writer object
type Midlog ¶
type Midlog interface { //Ext is a method with write Object with log Ext(ext ExtMap) Midlog //GetExt is a method with get ext object GetExt() ExtMap //GetModule is a method with get Module name with logger GetModule() string //Info is a method with write a log with info level Info(pams ...interface{}) //Trace is a method with write a log with trace level Trace(pams ...interface{}) //Debug is a method with write a log with debug level Debug(pams ...interface{}) //Error1 is a method with write a log with error1 level Error1(pams ...interface{}) //Error2 is a method with write a log with error2 level Error2(pams ...interface{}) //Error3 is a method with write a log with error3 level Error3(pams ...interface{}) //Warn is a method with write a log with warn level Warn(pams ...interface{}) //InfoF is a method with write a log with info level and format with msgExp Infof(msgExp string, pams ...interface{}) //TraceF is a method with write a log with trace level and format with msgExp Tracef(msgExp string, pams ...interface{}) //DebugF is a method with write a log with debug level and format with msgExp Debugf(msgExp string, pams ...interface{}) //Error1F is a method with write a log with error1 level and format with msgExp Error1f(msgExp string, pams ...interface{}) //Error2F is a method with write a log with error2 level and format with msgExp Error2f(msgExp string, pams ...interface{}) //Error3F is a method with write a log with error3 level and format with msgExp Error3f(msgExp string, pams ...interface{}) //WarnF is a method with write a log with warn level and format with msgExp Warnf(msgExp string, pams ...interface{}) //LogF is a method with write a log with parameter level and format with msgExp Logf(level LogLevel, msgExp string, pams ...interface{}) //Log is a method with write a log with parameter level Log(level LogLevel, pams ...interface{}) }
Midlog is a interface with write log