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:file:enable": `Enable writing log to file`,
"log:hidetraceconsole": `Don't print trace log to console, if false, maybe performance impact`,
"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`,
}
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 { // Create New Logger Object New() Logger // New Modules init // namespace is service name, and version is service version Init(namespace, version string) // Return Service name ServiceName() string // Return Service version ServiceVersion() string // Set Logging Level, see LogLevel options SetLogLevel(level DebugLevel) // Set Logging File SetLogFile(LoggingFile) // Get Current Log Level GetLogLevel() (level DebugLevel) // If true, will be print to console SetPrintToConsole(pr bool) // Get current value of print to console GetPrintToConsole() (pr bool) // Hooks on new incoming logger SetOnLoggerHandler(f func(msg LoggerMessage, raw string)) // Set logger output format, default or json SetOutputFormat(OutputFormat) // Get current logger format GetOutputFormat() OutputFormat // Parsing logger message object to string format ParsingLog(msg LoggerMessage) (raw string) // Write byte to current io.writer Write(p []byte) (int, error) // Same format with fmt.Sprint Trace(format interface{}, input ...interface{}) // Same format with fmt.Sprint Debug(format interface{}, input ...interface{}) // Same format with fmt.Sprint Notice(format interface{}, input ...interface{}) // Same format with fmt.Sprint Info(format interface{}, input ...interface{}) // Same format with fmt.Sprint Warning(format interface{}, input ...interface{}) // Same format with fmt.Sprint Success(format interface{}, input ...interface{}) // Same format with fmt.Sprint Error(format interface{}, input ...interface{}) Logger // Return New default system logger NewSystemLogger() *log.Logger // Same format with fmt.Sprint Printf(string, ...interface{}) // Force Exit application 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"` HideTraceConsole bool `yaml:"hidetraceconsole" default:"false" desc:"log:hidetraceconsole"` 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"` }
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.