Documentation ¶
Index ¶
- Constants
- Variables
- func AtLevel(level zapcore.Level, msg string, fields ...zapcore.Field)
- func Configure(config Config) error
- func ConsoleLogTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func ContextWithCustomizedLogger(ctx context.Context, logEntry *LogEntry) context.Context
- func ContextWithLogger(ctx context.Context) context.Context
- func DPanic(msg string)
- func DPanicWith(msg string, fields Fields)
- func DPanicf(template string, args ...interface{})
- func DPanicv(msg string, fields ...zapcore.Field)
- func DPanicw(msg string, keysAndValues ...interface{})
- func Debug(msg string)
- func DebugWith(msg string, fields Fields)
- func Debugf(template string, args ...interface{})
- func Debugv(msg string, fields ...zapcore.Field)
- func Debugw(msg string, keysAndValues ...interface{})
- func DeclareLogger(config Config, logv func(msg string, fields ...zapcore.Field))
- func Error(msg string)
- func ErrorWith(msg string, fields Fields)
- func Errorf(template string, args ...interface{})
- func Errorv(msg string, fields ...zapcore.Field)
- func Errorw(msg string, keysAndValues ...interface{})
- func Fatal(msg string)
- func FatalWith(msg string, fields Fields)
- func Fatalf(template string, args ...interface{})
- func Fatalv(msg string, fields ...zapcore.Field)
- func Fatalw(msg string, keysAndValues ...interface{})
- func Info(msg string)
- func InfoWith(msg string, fields Fields)
- func Infof(template string, args ...interface{})
- func Infov(msg string, fields ...zapcore.Field)
- func Infow(msg string, keysAndValues ...interface{})
- func Panic(msg string)
- func PanicWith(msg string, fields Fields)
- func Panicf(template string, args ...interface{})
- func Panicv(msg string, fields ...zapcore.Field)
- func Panicw(msg string, keysAndValues ...interface{})
- func SetLevel(l Level)
- func ShortTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
- func Warn(msg string)
- func WarnWith(msg string, fields Fields)
- func Warnf(template string, args ...interface{})
- func Warnv(msg string, fields ...zapcore.Field)
- func Warnw(msg string, keysAndValues ...interface{})
- type Config
- type Fields
- type Level
- type LogEntry
- func (le *LogEntry) ContextWithLogger(ctx context.Context) context.Context
- func (le *LogEntry) DPanic(msg string)
- func (le *LogEntry) DPanicWith(msg string, fields Fields)
- func (le *LogEntry) DPanicf(template string, args ...interface{})
- func (le *LogEntry) DPanicln(args ...interface{})
- func (le *LogEntry) DPanicv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) DPanicw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Debug(msg string)
- func (le *LogEntry) DebugWith(msg string, fields Fields)
- func (le *LogEntry) Debugf(template string, args ...interface{})
- func (le *LogEntry) Debugln(args ...interface{})
- func (le *LogEntry) Debugv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Debugw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Error(msg string)
- func (le *LogEntry) ErrorWith(msg string, fields Fields)
- func (le *LogEntry) Errorf(template string, args ...interface{})
- func (le *LogEntry) Errorln(args ...interface{})
- func (le *LogEntry) Errorv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Errorw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Fatal(msg string)
- func (le *LogEntry) FatalWith(msg string, fields Fields)
- func (le *LogEntry) Fatalf(template string, args ...interface{})
- func (le *LogEntry) Fatalln(args ...interface{})
- func (le *LogEntry) Fatalv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Fatalw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Info(msg string)
- func (le *LogEntry) InfoWith(msg string, fields Fields)
- func (le *LogEntry) Infof(template string, args ...interface{})
- func (le *LogEntry) Infoln(args ...interface{})
- func (le *LogEntry) Infov(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Infow(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Panic(msg string)
- func (le *LogEntry) PanicWith(msg string, fields Fields)
- func (le *LogEntry) Panicf(template string, args ...interface{})
- func (le *LogEntry) Panicln(args ...interface{})
- func (le *LogEntry) Panicv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Panicw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) Warn(msg string)
- func (le *LogEntry) WarnWith(msg string, fields Fields)
- func (le *LogEntry) Warnf(template string, args ...interface{})
- func (le *LogEntry) Warnln(args ...interface{})
- func (le *LogEntry) Warnv(msg string, fields ...zapcore.Field)
- func (le *LogEntry) Warnw(msg string, keysAndValues ...interface{})
- func (le *LogEntry) WithFields(f Fields) *LogEntry
Constants ¶
View Source
const ( DebugLevel = zapcore.DebugLevel InfoLevel = zapcore.InfoLevel WarnLevel = zapcore.WarnLevel ErrorLevel = zapcore.ErrorLevel DPanicLevel = zapcore.DPanicLevel PanicLevel = zapcore.PanicLevel FatalLevel = zapcore.FatalLevel )
View Source
const DefaultFieldName = "-"
Variables ¶
View Source
var DefaultRotateLoggerConfig = &Config{ Level: DebugLevel, EncodeLogsAsJson: true, CallerEnabled: true, CallerSkip: 1, ConsoleSeparator: "", LevelEncoder: zapcore.LowercaseLevelEncoder, Directory: "logs", Filename: filepath.Base(os.Args[0]), FileLoggingEnabled: true, MaxSize: 128, MaxBackups: 10, MaxAge: 90, }
DefaultZapLogger is the default logger instance that should be used to log It's assigned a default value here for tests (which do not call log.Configure())
Functions ¶
func ConsoleLogTimeEncoder ¶
func ConsoleLogTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
ConsoleLogTimeEncoder serializes a time.Time to an short-formatted string
func DPanicWith ¶
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf Log a format message at the debug level
func DeclareLogger ¶
func ShortTimeEncoder ¶
func ShortTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)
ShortTimeEncoder serializes a time.Time to an short-formatted string
Types ¶
type Config ¶
type Config struct { // Level set log level Level zapcore.Level // EncodeLogsAsJson makes the log framework log JSON EncodeLogsAsJson bool // FileLoggingEnabled makes the framework log to a file FileLoggingEnabled bool // ConsoleLoggingEnabled makes the framework log to console ConsoleLoggingEnabled bool // CallerEnabled makes the caller log to a file CallerEnabled bool // CallerSkip increases the number of callers skipped by caller CallerSkip int // Directory to log to when file logging is enabled Directory string // Filename is the name of the log file which will be placed inside the directory Filename string // MaxSize is the maximum size in megabytes of the log file before it gets // rotated. It defaults to 100 megabytes. MaxSize int // MaxBackups the max number of rolled files to keep MaxBackups int // MaxAge the max age in days to keep a log file MaxAge int // ConsoleInfoStream ConsoleInfoStream *os.File // ConsoleErrorStream ConsoleErrorStream *os.File // ConsoleSeparator the separator of fields of the log record ConsoleSeparator string // LevelEncoder use lowercase or capital case encoder LevelEncoder zapcore.LevelEncoder }
Config for logging
type LogEntry ¶
type LogEntry struct {
// contains filtered or unexported fields
}
func FromContext ¶
func NewLogEntry ¶
NewLogEntry create a new logentry instead of override defaultzaplogger
func WithFields ¶
func (*LogEntry) ContextWithLogger ¶
func (*LogEntry) DPanicWith ¶
func (*LogEntry) WithFields ¶
Click to show internal directories.
Click to hide internal directories.