Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func Debugc(ctx context.Context, msgFormat string, args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorc(ctx context.Context, msgFormat string, args ...interface{})
- func Errorf(msgFormat string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalc(ctx context.Context, msgFormat string, args ...interface{})
- func Fatalf(msgFormat string, args ...interface{})
- func Info(args ...interface{})
- func Infoc(ctx context.Context, msgFormat string, args ...interface{})
- func Infof(msgFormat string, args ...interface{})
- func Panic(args ...interface{})
- func Panicc(ctx context.Context, msgFormat string, args ...interface{})
- func Panicf(msgFormat string, args ...interface{})
- func ReplaceGlobal(logger *ZapLogger)
- func Warn(args ...interface{})
- func Warnc(ctx context.Context, msgFormat string, args ...interface{})
- func Warnf(msgFormat string, args ...interface{})
- type ContextExtractor
- type ContextExtractors
- type ContextualLogger
- type FiledKey
- type Logger
- type OptionFunc
- type Options
- type Properties
- type StdLogger
- type TestingLogger
- type TestingWriter
- type ZapLogger
- func (l *ZapLogger) Clone(addedCallerSkip int, fields ...field.Field) *ZapLogger
- func (l *ZapLogger) Debug(args ...interface{})
- func (l *ZapLogger) Debugc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Debugf(template string, args ...interface{})
- func (l *ZapLogger) Error(args ...interface{})
- func (l *ZapLogger) Errorc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Errorf(template string, args ...interface{})
- func (l *ZapLogger) Fatal(args ...interface{})
- func (l *ZapLogger) Fatalc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Fatalf(template string, args ...interface{})
- func (l *ZapLogger) Info(args ...interface{})
- func (l *ZapLogger) Infoc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Infof(template string, args ...interface{})
- func (l *ZapLogger) Panic(args ...interface{})
- func (l *ZapLogger) Panicc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Panicf(template string, args ...interface{})
- func (l *ZapLogger) Warn(args ...interface{})
- func (l *ZapLogger) Warnc(ctx context.Context, template string, args ...interface{})
- func (l *ZapLogger) Warnf(template string, args ...interface{})
- func (l *ZapLogger) WithAny(key string, value interface{}) Logger
- func (l *ZapLogger) WithCtx(ctx context.Context, additionalFields ...field.Field) Logger
- func (l *ZapLogger) WithError(err error) Logger
- func (l *ZapLogger) WithErrors(errs ...error) Logger
- func (l *ZapLogger) WithField(fields ...field.Field) Logger
Constants ¶
View Source
const ( OutputModeJson = "json" OutputModeConsole = "console" )
Variables ¶
This section is empty.
Functions ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf uses fmt.Sprintf to log a template message.
func Errorf ¶
func Errorf(msgFormat string, args ...interface{})
Errorf uses fmt.Sprintf to log a template message.
func Fatal ¶
func Fatal(args ...interface{})
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
func Fatalf ¶
func Fatalf(msgFormat string, args ...interface{})
Fatalf uses fmt.Sprintf to log a template message, then calls os.Exit.
func Infof ¶
func Infof(msgFormat string, args ...interface{})
Infof uses fmt.Sprintf to log a template message.
func Panic ¶ added in v0.15.0
func Panic(args ...interface{})
Panic uses fmt.Sprint to construct and log a message, then panics.
func Panicf ¶ added in v0.15.0
func Panicf(msgFormat string, args ...interface{})
Panicf uses fmt.Sprintf to log a templated message, then panics.
func ReplaceGlobal ¶
func ReplaceGlobal(logger *ZapLogger)
ReplaceGlobal Register a logger instance as global
Types ¶
type ContextExtractor ¶ added in v0.15.0
type ContextExtractors ¶ added in v0.15.0
type ContextExtractors []ContextExtractor
func (ContextExtractors) Extract ¶ added in v0.15.0
func (c ContextExtractors) Extract(ctx context.Context) []field.Field
func (ContextExtractors) IsExtractable ¶ added in v0.15.0
func (c ContextExtractors) IsExtractable() bool
type ContextualLogger ¶ added in v0.16.0
type ContextualLogger interface { // Debugc formats the message according to the format specifier // with some additional info in the context and logs it at debug level. Debugc(ctx context.Context, template string, args ...interface{}) // Infoc formats the message according to the format specifier // with some additional info in the context and logs it at info level. Infoc(ctx context.Context, template string, args ...interface{}) // Warnc formats the message according to the format specifier // with some additional info in the context and logs it at warn level. Warnc(ctx context.Context, template string, args ...interface{}) // Errorc formats the message according to the format specifier // with some additional info in the context and logs it at error level. Errorc(ctx context.Context, template string, args ...interface{}) // Fatalc formats the message according to the format specifier // with some additional info in the context and calls os.Exit. Fatalc(ctx context.Context, template string, args ...interface{}) // Panicc formats the message according to the format specifier // with some additional info in the context and panics. Panicc(ctx context.Context, template string, args ...interface{}) }
type Logger ¶
type Logger interface { StdLogger ContextualLogger // WithCtx adds additional info in the context and // additional fields to the logging context. WithCtx(ctx context.Context, additionalFields ...field.Field) Logger // WithField adds a variadic number of fields to the logging context. WithField(fields ...field.Field) Logger // WithError adds an error with FieldKeyErr field to the logging context. WithError(err error) Logger // WithErrors adds a field with FieldKeyErr field that carries a slice of errors. WithErrors(errs ...error) Logger // WithAny adds a key and an arbitrary value and chooses the best way to represent // them as a field. WithAny(key string, value interface{}) Logger }
func WithErrors ¶ added in v0.15.0
type OptionFunc ¶
type OptionFunc func(opt *Options)
func AddCallerSkip ¶
func AddCallerSkip(skip int) OptionFunc
type Options ¶
type Options struct { // Development puts the logger in development mode, which changes the // behavior of DPanicLevel and takes stack traces more liberally. Development bool // LogLevel is the minimum enabled logging level. // In Development mode, LogLevel will be set to DEBUG, // Opposite, LogLevel will be set to INFO mode automatically. LogLevel string // JsonOutputMode Enable or disable json output mode. JsonOutputMode bool // DisableCaller stops annotating logs with the calling function's file // name and line number. By default, all logs are annotated. DisableCaller bool // DisableStacktrace completely disables automatic stacktrace capturing. By // default, stacktrace-s are captured for WarnLevel and above logs in // development and ErrorLevel and above in production. DisableStacktrace bool // CallerSkip Set the number of callers // will be skipped before show caller CallerSkip int // FieldKeyMap Set the keys used for each log entry. // If any key is empty, that portion of the entry is omitted. FieldKeyMap map[FiledKey]string // ContextExtractors Define the list of extractors // that will be used when extract value from log context. ContextExtractors ContextExtractors }
type Properties ¶
type Properties struct { // Development puts the logger in development mode, which changes the // behavior of DPanicLevel and takes stack traces more liberally. Development bool `default:"false"` // LogLevel is the minimum enabled logging level. // In Development mode, LogLevel will be set to DEBUG, // Opposite, LogLevel will be set to INFO mode automatically. LogLevel string // JsonOutputMode Enable or disable json output mode. JsonOutputMode bool `default:"true"` // DisableCaller stops annotating logs with the calling function's file // name and line number. By default, all logs are annotated. DisableCaller bool // DisableStacktrace completely disables automatic stacktrace capturing. By // default, stacktrace-s are captured for WarnLevel and above logs in // development and ErrorLevel and above in production. DisableStacktrace bool // CallerSkip Set the number of callers // will be skipped before show caller CallerSkip int `default:"1"` }
func NewProperties ¶
func NewProperties(loader config.Loader) (*Properties, error)
func (Properties) Prefix ¶
func (l Properties) Prefix() string
type StdLogger ¶ added in v0.15.0
type StdLogger interface { // Debug logs the provided arguments at debug level. // Spaces are added between arguments when neither is a string. Debug(args ...interface{}) // Info logs the provided arguments at debug level. // Spaces are added between arguments when neither is a string. Info(args ...interface{}) // Warn logs the provided arguments at debug level. // Spaces are added between arguments when neither is a string. Warn(args ...interface{}) // Error logs the provided arguments at debug level. // Spaces are added between arguments when neither is a string. Error(args ...interface{}) // Fatal constructs a message with the provided arguments and calls os.Exit. // Spaces are added between arguments when neither is a string. Fatal(args ...interface{}) // Panic constructs a message with the provided arguments and panics. // Spaces are added between arguments when neither is a string. Panic(args ...interface{}) // Debugf formats the message according to the format specifier // and logs it at debug level. Debugf(template string, args ...interface{}) // Infof formats the message according to the format specifier // and logs it at info level. Infof(template string, args ...interface{}) // Warnf formats the message according to the format specifier // and logs it at warn level. Warnf(template string, args ...interface{}) // Errorf formats the message according to the format specifier // and logs it at error level. Errorf(template string, args ...interface{}) // Fatalf formats the message according to the format specifier // and calls os.Exit. Fatalf(template string, args ...interface{}) // Panicf formats the message according to the format specifier // and panics. Panicf(template string, args ...interface{}) }
type TestingLogger ¶
type TestingLogger struct { *ZapLogger // contains filtered or unexported fields }
func NewTestingLogger ¶
func NewTestingLogger(tb testing.TB, options *Options) (*TestingLogger, error)
func NewTestingLoggerFromDefault ¶
func NewTestingLoggerFromDefault(tb testing.TB, defaultLogger *ZapLogger) *TestingLogger
type TestingWriter ¶
type TestingWriter struct {
// contains filtered or unexported fields
}
TestingWriter is a WriteSyncer that writes to the given testing.TB.
func NewTestingWriter ¶
func NewTestingWriter(tb testing.TB) TestingWriter
func (TestingWriter) Sync ¶
func (w TestingWriter) Sync() error
type ZapLogger ¶ added in v0.15.0
type ZapLogger struct {
// contains filtered or unexported fields
}
func NewZapLogger ¶ added in v0.15.0
func (*ZapLogger) WithErrors ¶ added in v0.15.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.