Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEncoder ¶
NewEncoder creates a fast, low-allocation encoder. The encoder appropriately escapes all field keys and values.
Note that the encoder doesn't deduplicate keys, so it's possible to produce a message like
{"foo":"bar","foo":"baz"}
This is permitted by the JSON specification, but not encouraged. Many libraries will ignore duplicate key-value pairs (typically keeping the last pair) when unmarshaling, but users should attempt to avoid adding duplicate keys.
Types ¶
type Config ¶
type Config struct {
// Level is the minimum enabled logging level. Note that this is a dynamic
// level, so calling Config.Level.SetLevel will atomically change the logger
// level of all loggers descended from this config.
Level zap.AtomicLevel `json:"level,omitempty" yaml:"level,omitempty"`
// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
Development bool `json:"development,omitempty" yaml:"development,omitempty"`
// DisableCaller stops annotating logs with the calling function's file
// name and line number. By default, all logs are annotated.
DisableCaller bool `json:"disableCaller,omitempty" yaml:"disableCaller,omitempty"`
// DisableStacktrace completely disables automatic stacktrace capturing. By
// default, stacktraces are captured for WarnLevel and above logs in
// development and ErrorLevel and above in production.
DisableStacktrace bool `json:"disableStacktrace,omitempty" yaml:"disableStacktrace,omitempty"`
// Sampling sets a sampling policy. A nil SamplingConfig disables sampling.
Sampling *zap.SamplingConfig `json:"sampling,omitempty" yaml:"sampling,omitempty"`
// OutputPaths is a list of URLs or file paths to write logging output to.
// See Open for details.
OutputPaths map[zapcore.Level]string `json:"outputPaths,omitempty" yaml:"outputPaths,omitempty"`
// 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:"errorOutputPaths,omitempty" yaml:"errorOutputPaths,omitempty"`
// InitialFields is a collection of fields to add to the root logger.
InitialFields map[string]interface{} `json:"initialFields,omitempty" yaml:"initialFields,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.