Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LoggerConfigManual = map[string]string{
"log:level": `logging level, valid value is
- trace
- verbose
- info
- warning
- error
`,
"log:format": `logging output format, valid value is
- default
- json
`,
"log:hideconsole": `Don't print log to console`,
"log:disablecolor": `Don't use color in log`,
"log:file:enable": `Enable writing log to file`,
"log:file:output": `File log output location`,
"log:file:maxsize": `Max log file size (in megabytes) before retain`,
"log:file:maxage": `Max log file age (in days) before retain`,
"log:file:compress": `If true, old file will be compressed`,
"log:file:json": `If true, always write in json format`,
}
Functions ¶
func GetLogLevelPrintString ¶
func GetLogLevelString ¶
Types ¶
type Caller ¶
type DebugLevel ¶
type DebugLevel int
const ( DebugLevelTrace DebugLevel = iota + 1 DebugLevelVerbose DebugLevelInfo DebugLevelWarning DebugLevelError )
func GetDebugLevelFromString ¶
func GetDebugLevelFromString(level string) DebugLevel
type Logger ¶
type Logger interface { New() Logger Init(namespace, version string) ServiceName() string ServiceVersion() string SetLogLevel(level DebugLevel) SetLogFile(LoggingFile) GetLogLevel() (level DebugLevel) SetPrintToConsole(pr bool) GetPrintToConsole() (pr bool) DisableColor(val bool) SetOnLoggerHandler(f func(msg LoggerMessage, raw string)) SetOutputFormat(OutputFormat) GetOutputFormat() OutputFormat ParsingLog(msg LoggerMessage) (raw string) Write(p []byte) (int, error) Trace(format interface{}, input ...interface{}) Debug(format interface{}, input ...interface{}) Notice(format interface{}, input ...interface{}) Info(format interface{}, input ...interface{}) Warning(format interface{}, input ...interface{}) Success(format interface{}, input ...interface{}) Error(format interface{}, input ...interface{}) Logger Debugf(format string, input ...interface{}) Errorf(format string, input ...interface{}) Infof(format string, input ...interface{}) Warnf(format string, input ...interface{}) NewSystemLogger() *log.Logger Printf(string, ...interface{}) Quit() }
Logger modules interface, using for dynamic modules
type LoggerConfig ¶
type LoggerConfig struct { Level string `yaml:"level" default:"verbose" desc:"log:level"` Format string `yaml:"format" default:"default" desc:"log:format"` HideConsole bool `yaml:"hideconsole" default:"false" desc:"log:hideconsole"` DisableColor bool `yaml:"disablecolor" default:"false" desc:"log:disablecolor"` File LoggingFile `yaml:"file"` }
type LoggerMessage ¶
type LoggingFile ¶
type LoggingFile struct { Enable bool `yaml:"enable" default:"false" desc:"log:file:enable"` Output string `yaml:"output" default:"./logs/app.log" desc:"log:file:output"` MaxSize int `yaml:"maxsize" default:"100" desc:"log:file:maxsize"` MaxAge int `yaml:"maxage" default:"28" desc:"log:file:maxage"` Compress bool `yaml:"compress" default:"false" desc:"log:file:compress"` Json bool `yaml:"json" default:"false" desc:"log:file:json"` }
type OutputFormat ¶
type OutputFormat int
const ( OutputFormatDefault OutputFormat = iota + 1 OutputFormatJSON )
func GetOutputFormatFromString ¶
func GetOutputFormatFromString(op string) OutputFormat
Click to show internal directories.
Click to hide internal directories.