Documentation
¶
Index ¶
- Constants
- func New(level zap.AtomicLevel, opts ...func(*Options)) *zap.Logger
- func NewConsoleEncoder(cfg *zapcore.EncoderConfig, noColor *bool) zapcore.Encoder
- func SymbolLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func WithFileLogger(cfg FileLoggerConfig) func(*Options)
- func WithNoColor(noColor *bool) func(*Options)
- func WithWriter(w io.Writer) func(*Options)
- type FileLoggerConfig
- type Options
Constants ¶
const ( // SuccessName is a designated logging name which prints // messages with a [✔] symbol rather than their regular // log level. SuccessName = "clio.success" // NoPrefixName is a designated logging name which prints // messages without a prefix. NoPrefixName = "clio.noprefix" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(level zap.AtomicLevel, opts ...func(*Options)) *zap.Logger
New returns a CLI-friendly zap logger which prints to stderr by default.
func NewConsoleEncoder ¶
func NewConsoleEncoder(cfg *zapcore.EncoderConfig, noColor *bool) zapcore.Encoder
NewConsoleEncoder creates an encoder whose output is designed for human - rather than machine - consumption. It serializes the core log entry data (message, level, timestamp, etc.) in a plain-text format. The context is encoded in LTSV.
Note that although the console encoder doesn't use the keys specified in the encoder configuration, it will omit any element whose key is set to the empty string.
func SymbolLevelEncoder ¶
func SymbolLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
SymbolLevelEncoder serializes a Level to a symbol. The mapping is as follows:
INFO: [i] ERROR: [✘] WARN: [!] DEBUG: [DEBUG]
func WithFileLogger ¶ added in v1.2.0
func WithFileLogger(cfg FileLoggerConfig) func(*Options)
WithFileLogger will write logs to a file using lumberjack package in addition to printing it in console.
func WithNoColor ¶
WithNoColor sets up a colorization bypass.
func WithWriter ¶
WithWriter specifies an io.Writer to write logs to.
Types ¶
type FileLoggerConfig ¶ added in v1.2.0
type FileLoggerConfig struct { // Name of your log file Filename string // Maximum size of the log file in MB before it gets rotated. // If set to 0 the default max size is used (1 MB) MaxSize int // Maximum number of old log files to retain. // If set to 0 the default is 30 MaxBackups int // Maximum number of days to retain old log files based on the timestamp encoded in their filename. // If set to 0 the default is 90 days MaxAge int // ShouldCompress if set to true will compress the rotated log files using gzip. ShouldCompress bool }