zaplog

package module
v0.0.0-...-4ec7b33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2017 License: MIT Imports: 8 Imported by: 1

README

zaplog是包装了zap, 带caller func name, 兼容logrus stdlog 的日志输出工具

GoDoc Go Report Card code-coverage

Document

func FormatStdLog()
    FormatStdLog set the output of stand package log to zaplog

func NewCustomLogger(debugLevel bool, te zapcore.TimeEncoder, de zapcore.DurationEncoder) (logger *zap.Logger)
    NewCustomLogger return a normal logger with given timeEncoder

func NewLogger(debugLevel bool) (logger *zap.Logger)
    NewLogger return a normal logger

func NewNoCallerLogger(debugLevel bool) (noCallerLogger *zap.Logger)
    NewNoCallerLogger return a no caller key value, will be faster

func NewNormalLoggers(debugLevel bool) (logger, noCallerLogger *zap.Logger)
    NewNormalLoggers is a shortcut to get normal logger, noCallerLogger.

TYPES

type CompatibleLogger struct {
    // contains filtered or unexported fields
}
    CompatibleLogger is a logger which compatible to logrus/std
    log/prometheus. it implements Print() Println() Printf() Dbug()
    Debugln() Debugf() Info() Infoln() Infof() Warn() Warnln() Warnf()
    Error() Errorln() Errorf() Fatal() Fataln() Fatalf() Panic() Panicln()
    Panicf() With() WithField() WithFields()

func NewCompatibleLogger(debugLevel bool) *CompatibleLogger
    NewCompatibleLogger return CompatibleLogger with caller field

func (l CompatibleLogger) Debug(args ...interface{})
    Debug logs a message at level Debug on the compatibleLogger.

func (l CompatibleLogger) Debugf(format string, args ...interface{})
    Debugf logs a message at level Debug on the compatibleLogger.

func (l CompatibleLogger) Debugln(args ...interface{})
    Debugln logs a message at level Debug on the compatibleLogger.

func (l CompatibleLogger) Error(args ...interface{})
    Error logs a message at level Error on the compatibleLogger.

func (l CompatibleLogger) Errorf(format string, args ...interface{})
    Errorf logs a message at level Error on the compatibleLogger.

func (l CompatibleLogger) Errorln(args ...interface{})
    Errorln logs a message at level Error on the compatibleLogger.

func (l CompatibleLogger) Fatal(args ...interface{})
    Fatal logs a message at level Fatal on the compatibleLogger.

func (l CompatibleLogger) Fatalf(format string, args ...interface{})
    Fatalf logs a message at level Fatal on the compatibleLogger.

func (l CompatibleLogger) Fatalln(args ...interface{})
    Fatalln logs a message at level Fatal on the compatibleLogger.

func (l CompatibleLogger) Info(args ...interface{})
    Info logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Infof(format string, args ...interface{})
    Infof logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Infoln(args ...interface{})
    Infoln logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Panic(args ...interface{})
    Panic logs a message at level Painc on the compatibleLogger.

func (l CompatibleLogger) Panicf(format string, args ...interface{})
    Panicf logs a message at level Painc on the compatibleLogger.

func (l CompatibleLogger) Panicln(args ...interface{})
    Panicln logs a message at level Painc on the compatibleLogger.

func (l CompatibleLogger) Print(args ...interface{})
    Print logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Printf(format string, args ...interface{})
    Printf logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Println(args ...interface{})
    Println logs a message at level Info on the compatibleLogger.

func (l CompatibleLogger) Warn(args ...interface{})
    Warn logs a message at level Warn on the compatibleLogger.

func (l CompatibleLogger) Warnf(format string, args ...interface{})
    Warnf logs a message at level Warn on the compatibleLogger.

func (l CompatibleLogger) Warnln(args ...interface{})
    Warnln logs a message at level Warn on the compatibleLogger.

func (l *CompatibleLogger) With(key string, value interface{}) *CompatibleLogger
    With return a logger with an extra field.

func (l *CompatibleLogger) WithField(key string, value interface{}) *CompatibleLogger
    WithField return a logger with an extra field.

func (l *CompatibleLogger) WithFields(fields map[string]interface{}) *CompatibleLogger
    WithFields return a logger with extra fields.


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatStdLog

func FormatStdLog()

FormatStdLog set the output of stand package log to zaplog

func NewCustomLogger

func NewCustomLogger(debugLevel bool, te zapcore.TimeEncoder, de zapcore.DurationEncoder) (logger *zap.Logger)

NewCustomLogger return a normal logger with given timeEncoder

func NewLogger

func NewLogger(debugLevel bool) (logger *zap.Logger)

NewLogger return a normal logger

func NewNoCallerLogger

func NewNoCallerLogger(debugLevel bool) (noCallerLogger *zap.Logger)

NewNoCallerLogger return a no caller key value, will be faster

func NewNormalLoggers

func NewNormalLoggers(debugLevel bool) (logger, noCallerLogger *zap.Logger)

NewNormalLoggers is a shortcut to get normal logger, noCallerLogger.

Types

type CompatibleLogger

type CompatibleLogger struct {
	// contains filtered or unexported fields
}

CompatibleLogger is a logger which compatible to logrus/std log/prometheus. it implements Print() Println() Printf() Dbug() Debugln() Debugf() Info() Infoln() Infof() Warn() Warnln() Warnf() Error() Errorln() Errorf() Fatal() Fataln() Fatalf() Panic() Panicln() Panicf() With() WithField() WithFields()

func NewCompatibleLogger

func NewCompatibleLogger(debugLevel bool) *CompatibleLogger

NewCompatibleLogger return CompatibleLogger with caller field

func (CompatibleLogger) Debug

func (l CompatibleLogger) Debug(args ...interface{})

Debug logs a message at level Debug on the compatibleLogger.

func (CompatibleLogger) Debugf

func (l CompatibleLogger) Debugf(format string, args ...interface{})

Debugf logs a message at level Debug on the compatibleLogger.

func (CompatibleLogger) Debugln

func (l CompatibleLogger) Debugln(args ...interface{})

Debugln logs a message at level Debug on the compatibleLogger.

func (CompatibleLogger) Error

func (l CompatibleLogger) Error(args ...interface{})

Error logs a message at level Error on the compatibleLogger.

func (CompatibleLogger) Errorf

func (l CompatibleLogger) Errorf(format string, args ...interface{})

Errorf logs a message at level Error on the compatibleLogger.

func (CompatibleLogger) Errorln

func (l CompatibleLogger) Errorln(args ...interface{})

Errorln logs a message at level Error on the compatibleLogger.

func (CompatibleLogger) Fatal

func (l CompatibleLogger) Fatal(args ...interface{})

Fatal logs a message at level Fatal on the compatibleLogger.

func (CompatibleLogger) Fatalf

func (l CompatibleLogger) Fatalf(format string, args ...interface{})

Fatalf logs a message at level Fatal on the compatibleLogger.

func (CompatibleLogger) Fatalln

func (l CompatibleLogger) Fatalln(args ...interface{})

Fatalln logs a message at level Fatal on the compatibleLogger.

func (CompatibleLogger) Info

func (l CompatibleLogger) Info(args ...interface{})

Info logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Infof

func (l CompatibleLogger) Infof(format string, args ...interface{})

Infof logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Infoln

func (l CompatibleLogger) Infoln(args ...interface{})

Infoln logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Panic

func (l CompatibleLogger) Panic(args ...interface{})

Panic logs a message at level Painc on the compatibleLogger.

func (CompatibleLogger) Panicf

func (l CompatibleLogger) Panicf(format string, args ...interface{})

Panicf logs a message at level Painc on the compatibleLogger.

func (CompatibleLogger) Panicln

func (l CompatibleLogger) Panicln(args ...interface{})

Panicln logs a message at level Painc on the compatibleLogger.

func (CompatibleLogger) Print

func (l CompatibleLogger) Print(args ...interface{})

Print logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Printf

func (l CompatibleLogger) Printf(format string, args ...interface{})

Printf logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Println

func (l CompatibleLogger) Println(args ...interface{})

Println logs a message at level Info on the compatibleLogger.

func (CompatibleLogger) Warn

func (l CompatibleLogger) Warn(args ...interface{})

Warn logs a message at level Warn on the compatibleLogger.

func (CompatibleLogger) Warnf

func (l CompatibleLogger) Warnf(format string, args ...interface{})

Warnf logs a message at level Warn on the compatibleLogger.

func (CompatibleLogger) Warnln

func (l CompatibleLogger) Warnln(args ...interface{})

Warnln logs a message at level Warn on the compatibleLogger.

func (*CompatibleLogger) With

func (l *CompatibleLogger) With(key string, value interface{}) *CompatibleLogger

With return a logger with an extra field.

func (*CompatibleLogger) WithField

func (l *CompatibleLogger) WithField(key string, value interface{}) *CompatibleLogger

WithField return a logger with an extra field.

func (*CompatibleLogger) WithFields

func (l *CompatibleLogger) WithFields(fields map[string]interface{}) *CompatibleLogger

WithFields return a logger with extra fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL