Documentation ¶
Index ¶
- Variables
- func GetLogLevelPrintString(level LogLevel) string
- func GetLogLevelString(level LogLevel) string
- func SetManual(man map[string]string) map[string]string
- type Caller
- type DatadogTraceLog
- type DebugLevel
- type LogLevel
- type Logger
- type LoggerConfig
- type LoggerMessage
- type LoggingFile
- type OutputFormat
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": `Directory 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": `Compress the backup files (older than max age) in gzip format`,
"log:sendToDataDog": `Send every logs to datadog`,
"log:logNoOfChunk": `How to many logs send to exporter at once`,
"log:logSendInterval": `Time interval to send logs to exporter, in ms, default 200ms`,
"log:datadogExporterContentEncoding": `datadog exporter content encoding, valid value is
- gzip
- deflate
- identity
`,
}
Functions ¶
func GetLogLevelPrintString ¶
func GetLogLevelString ¶
Types ¶
type Caller ¶
type DatadogTraceLog ¶ added in v0.0.5
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 - Clone logger instance New() Logger // Init - Deprecated, use InitWithConfig instead Init(namespace, version string) InitWithConfig(namespace, version string, config *LoggerConfig) // Close - Close logger instance, this will block until all log has been sent Close() // CloseWithTimeout - Close logger instance with timeout, this will block until all log has been sent CloseWithTimeout(timeout time.Duration) ServiceName() string ServiceVersion() string SetLogLevel(level DebugLevel) SetLogFile(*LoggingFile) GetLogLevel() (level DebugLevel) SetPrintToConsole(pr bool) GetPrintToConsole() (pr bool) SetOnLoggerHandler(f func(msg LoggerMessage, raw string)) SetOutputFormat(OutputFormat) GetOutputFormat() OutputFormat ParsingLog(msg LoggerMessage) (raw string) SetSendToDatadog(send bool) SetLogNoOfChunk(cc int) SetLogSendInterval(cc int) SetDatadogExporterContentEncoding(en 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 NewSystemLogger() *log.Logger Printf(string, ...interface{}) Quit() // Clean - Clean logger instance, send interrupt signal to this group process Clean() Logger // Kill - Kill logger instance, send interrupt signal to this process Kill() // SendDataDogTraceLog - Send datadog trace log // DD_API_KEY and DD_SITE must be set SendDataDogTraceLog(data *DatadogTraceLog) // RunDatadogTraceLogExporter - Start datadog trace log exporter RunDatadogTraceLogExporter() }
Logger modules interface, using for dynamic modules
type LoggerConfig ¶
type LoggerConfig struct { Level string `yaml:"level" default:"verbose" desc:"log:level" validate:"oneof=trace verbose info warning error"` Format string `yaml:"format" default:"default" desc:"log:format" validate:"oneof=default json"` File *LoggingFile `yaml:"file"` SendToDataDog bool `yaml:"sendToDataDog" desc:"log:sendToDataDog"` LogNoOfChunk int `yaml:"logNoOfChunk" default:"10" desc:"log:logNoOfChunk" validate:"min=10,max=1000"` LogSendInterval int `yaml:"logSendInterval" default:"200" desc:"log:logSendInterval" validate:"min=100,max=3000"` DatadogExporterContentEncoding string `` /* 136-byte string literal not displayed */ }
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" desc:"log:file:compress"` }
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.