Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type ConsoleEncoder
- func (e *ConsoleEncoder) DisableCaller() bool
- func (e *ConsoleEncoder) DisableFunction() bool
- func (e *ConsoleEncoder) DisableLevel() bool
- func (e *ConsoleEncoder) DisableName() bool
- func (e *ConsoleEncoder) DisableStacktrace() bool
- func (e *ConsoleEncoder) DisableTime() bool
- func (e *ConsoleEncoder) PreModify() (nc any, modified bool)
- func (e *ConsoleEncoder) SkipLineEnding() bool
- type JsonEncoder
- type LoggerConfig
- type Module
Constants ¶
View Source
const DefaultTimeLayout = "2006-01-02 15:04:05.999999999"
Variables ¶
View Source
var ( LogConfigNotFoundError = errors.New("log config not found") InvalidLogEncodingError = errors.New("invalid log encoding") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { LoggerConfig `yaml:",inline"` Configs map[string]*LoggerConfig `yaml:",inline" json:"configs" default:"{}"` Modules map[string]string `yaml:"modules" json:"modules" default:"{}"` }
type ConsoleEncoder ¶
type ConsoleEncoder struct { // Set the keys used for each log entry. If any key is empty, that portion // of the entry is omitted. DisableLevelP *bool `json:"disable-level" yaml:"disable-level"` DisableTimeP *bool `json:"disable-time" yaml:"disable-time"` DisableNameP *bool `json:"disable-name" yaml:"disable-name"` DisableCallerP *bool `json:"disable-caller" yaml:"disable-caller" default:"true"` DisableFunctionP *bool `json:"disable-function" yaml:"disable-function" default:"true"` DisableStacktraceP *bool `json:"disable-stacktrace" yaml:"disable-stacktrace" default:"true"` SkipLineEndingP *bool `json:"skip-line-ending" yaml:"skip-line-ending"` LineEnding string `json:"line-ending" yaml:"line-ending"` // Configure the primitive representations of common complex types. For // example, some users may want all time.Times serialized as floating-point // seconds since epoch, while others may prefer ISO8601 strings. EncodeLevel log.LevelEncoder `json:"level-encoder" yaml:"level-encoder"` EncodeTime log.TimeEncoder `json:"time-encoder" yaml:"time-encoder"` EncodeDuration log.DurationEncoder `json:"duration-encoder" yaml:"duration-encoder"` EncodeCaller log.CallerEncoder `json:"caller-encoder" yaml:"caller-encoder"` // Unlike the other primitive type encoders, EncodeName is optional. The // zero value falls back to FullNameEncoder. EncodeName log.NameEncoder `json:"name-encoder" yaml:"name-encoder"` // Configures the field separator used by the console encoder. Defaults // to tab. ConsoleSeparator string `json:"console-separator" yaml:"console-separator"` }
func (*ConsoleEncoder) DisableCaller ¶
func (e *ConsoleEncoder) DisableCaller() bool
func (*ConsoleEncoder) DisableFunction ¶
func (e *ConsoleEncoder) DisableFunction() bool
func (*ConsoleEncoder) DisableLevel ¶
func (e *ConsoleEncoder) DisableLevel() bool
func (*ConsoleEncoder) DisableName ¶
func (e *ConsoleEncoder) DisableName() bool
func (*ConsoleEncoder) DisableStacktrace ¶
func (e *ConsoleEncoder) DisableStacktrace() bool
func (*ConsoleEncoder) DisableTime ¶
func (e *ConsoleEncoder) DisableTime() bool
func (*ConsoleEncoder) PreModify ¶
func (e *ConsoleEncoder) PreModify() (nc any, modified bool)
func (*ConsoleEncoder) SkipLineEnding ¶
func (e *ConsoleEncoder) SkipLineEnding() bool
type JsonEncoder ¶
type JsonEncoder struct { // Set the keys used for each log entry. If any key is empty, that portion // of the entry is omitted. MessageKey string `json:"message-key" yaml:"message-key" default:"msg"` LevelKey string `json:"level-key" yaml:"level-key" default:"level"` TimeKey string `json:"time-key" yaml:"time-key" default:"time"` NameKey string `json:"name-key" yaml:"name-key" default:"logger"` CallerKey string `json:"caller-key" yaml:"caller-key" default:"caller"` FunctionKey string `json:"function-key" yaml:"function-key" default:"func"` StacktraceKey string `json:"stacktrace-key" yaml:"stacktrace-key"` SkipLineEndingP *bool `json:"skip-line-ending" yaml:"skip-line-ending"` LineEnding string `json:"line-ending" yaml:"line-ending"` EscapeESCP *bool `json:"escape-esc" yaml:"escape-esc"` // Configure the primitive representations of common complex types. For // example, some users may want all time.Times serialized as floating-point // seconds since epoch, while others may prefer ISO8601 strings. EncodeLevel log.LevelEncoder `json:"level-encoder" yaml:"level-encoder"` EncodeTime log.TimeEncoder `json:"time-encoder" yaml:"time-encoder"` EncodeDuration log.DurationEncoder `json:"duration-encoder" yaml:"duration-encoder"` EncodeCaller log.CallerEncoder `json:"caller-encoder" yaml:"caller-encoder"` // Unlike the other primitive type encoders, EncodeName is optional. The // zero value falls back to FullNameEncoder. EncodeName log.NameEncoder `json:"name-encoder" yaml:"name-encoder"` }
func (*JsonEncoder) EscapeESC ¶
func (e *JsonEncoder) EscapeESC() bool
func (*JsonEncoder) PreModify ¶
func (e *JsonEncoder) PreModify() (nc any, modified bool)
func (*JsonEncoder) SkipLineEnding ¶
func (e *JsonEncoder) SkipLineEnding() bool
type LoggerConfig ¶
type LoggerConfig struct { // Level is the minimum enabled logging level. Note that this is a dynamic // level, so calling Config.Level.SetLevel will atomically change the log // level of all loggers descended from this config. Level log.AtomicLevel `json:"level" yaml:"level"` // DevelopmentP puts the logger in development mode, which changes the // behavior of DPanicLevel and takes stacktraces more liberally. DevelopmentP *bool `json:"development" yaml:"development"` // DisableCallerP stops annotating logs with the calling function's file // name and line number. By default, all logs are annotated. DisableCallerP *bool `json:"disable-caller" yaml:"disable-caller"` // DisableStacktraceP completely disables automatic stacktrace capturing. By // default, stacktraces are captured for WarnLevel and above logs in // development and ErrorLevel and above in production. DisableStacktraceP *bool `json:"disable-stacktrace" yaml:"disable-stacktrace" default:"true"` // Sampling sets a sampling policy. A nil SamplingConfig disables sampling. Sampling *log.SamplingConfig `json:"sampling" yaml:"sampling"` // Encoding sets the logger's encoding. Valid values are "json" and // "console", as well as any third-party encodings registered via // RegisterEncoder. Encoding string `json:"encoding" yaml:"encoding" default:"console"` // OutputPaths is a list of URLs or file paths to write logging output to. // See Open for details. OutputPaths []string `json:"output-paths" yaml:"output-paths" default:"[stdout]"` // ErrorOutputPaths is a list of URLs to write internal logger errors to. // The default is standard error. // // Note that this setting only affects internal errors; for sample code that // sends error-level logs to a different location from info- and debug-level // logs, see the package-level AdvancedConfiguration example. ErrorOutputPaths []string `json:"error-output-paths" yaml:"error-output-paths" default:"[stderr]"` // InitialFields is a collection of fields to add to the root logger. InitialFields map[string]interface{} `json:"initial-fields" yaml:"initial-fields"` ConsoleEncoder ConsoleEncoder `yaml:"console-encoder" json:"console-encoder"` JsonEncoder JsonEncoder `yaml:"json-encoder" json:"json-encoder"` }
func (*LoggerConfig) Development ¶
func (c *LoggerConfig) Development() bool
func (*LoggerConfig) DisableCaller ¶
func (c *LoggerConfig) DisableCaller() bool
func (*LoggerConfig) DisableStacktrace ¶
func (c *LoggerConfig) DisableStacktrace() bool
func (*LoggerConfig) MustBuild ¶
func (c *LoggerConfig) MustBuild() *log.Logger
func (*LoggerConfig) PreModify ¶
func (c *LoggerConfig) PreModify() (nc any, modified bool)
Click to show internal directories.
Click to hide internal directories.