Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder)
- func DefaultTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func NewTextCore(enc zapcore.Encoder, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) zapcore.Core
- func NewTextEncoder(cfg *Config) zapcore.Encoder
- func ShortCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
- type Config
- type FileConfig
- type ZapProperties
Constants ¶
View Source
const DefaultLogTimeFormat = "2006-01-02T15:04:05.000000Z07:00"
Variables ¶
View Source
var (
// Get retrieves a buffer from the pool, creating one if necessary.
Get = _pool.Get
)
Functions ¶
func DefaultDurationEncoder ¶
func DefaultDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder)
func DefaultTimeEncoder ¶
func DefaultTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
DefaultTimeEncoder serializes time.Time to a human-readable formatted string
func NewTextCore ¶
func NewTextCore(enc zapcore.Encoder, ws zapcore.WriteSyncer, enab zapcore.LevelEnabler) zapcore.Core
NewTextCore creates a Core that writes logs to a WriteSyncer.
func NewTextEncoder ¶
NewTextEncoder creates a fast, low-allocation Text encoder. The encoder appropriately escapes all field keys and values.
func ShortCallerEncoder ¶
func ShortCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)
ShortCallerEncoder serializes a caller in file:line format.
Types ¶
type Config ¶
type Config struct { // Log level. Level zapcore.Level `toml:"level"` // Log format. one of json, text, or console. Format string `toml:"format"` // Disable automatic timestamps in output. DisableTimestamp bool `toml:"disable-timestamp"` // File log config. File FileConfig `toml:"file"` // Development puts the logger in development mode, which changes the // behavior of DPanicLevel and takes stacktraces more liberally. Development bool `toml:"development"` // DisableCaller stops annotating logs with the calling function's file // name and line number. By default, all logs are annotated. DisableCaller bool `toml:"disable-caller"` // 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 `toml:"disable-stacktrace"` // DisableErrorVerbose stops annotating logs with the full verbose error // message. DisableErrorVerbose bool `toml:"disable-error-verbose"` }
Config "comment"
type FileConfig ¶
type FileConfig struct { // Log filename, leave empty to disable file log. Filename string `toml:"filename"` // Max size for a single file, in MB. MaxSize int `toml:"max-size"` // Max log keep days, default is never deleting. MaxDays int `toml:"max-days"` // Maximum number of old log files to retain. MaxBackups int `toml:"max-backups"` }
FileConfig "comment"
type ZapProperties ¶
ZapProperties records some information about zap.
func InitLogger ¶
InitLogger initializes a zap logger.
func InitLoggerWithWriteSyncer ¶
func InitLoggerWithWriteSyncer(cfg *Config, output zapcore.WriteSyncer, opts ...zap.Option) (*zap.Logger, *ZapProperties, error)
InitLoggerWithWriteSyncer initializes a zap logger with specified write syncer.
Click to show internal directories.
Click to hide internal directories.