Documentation
¶
Overview ¶
Package logging provides an abstract interface used internally and which can provide interop with various logging packages. uber-go/zap is preferred.
Index ¶
- func Debug(ctx context.Context, msg string)
- func Debugf(ctx context.Context, msg string, args ...interface{})
- func Debugw(ctx context.Context, msg string, fields ...interface{})
- func EnsureLogger(ctx context.Context) context.Context
- func Error(ctx context.Context, msg string)
- func Errorf(ctx context.Context, msg string, args ...interface{})
- func Errorw(ctx context.Context, msg string, fields ...interface{})
- func Fatal(ctx context.Context, msg string)
- func Fatalf(ctx context.Context, msg string, args ...interface{})
- func Fatalw(ctx context.Context, msg string, fields ...interface{})
- func Info(ctx context.Context, msg string)
- func Infof(ctx context.Context, msg string, args ...interface{})
- func Infow(ctx context.Context, msg string, fields ...interface{})
- func Interceptor() grpc.UnaryServerInterceptor
- func Panic(ctx context.Context, msg string)
- func Panicf(ctx context.Context, msg string, args ...interface{})
- func Panicw(ctx context.Context, msg string, fields ...interface{})
- func Track(ctx context.Context, field string, value interface{})
- func Warn(ctx context.Context, msg string)
- func Warnf(ctx context.Context, msg string, args ...interface{})
- func Warnw(ctx context.Context, msg string, fields ...interface{})
- func With(ctx context.Context, logger Logger) context.Context
- type Logger
- type ZapLogger
- func (z *ZapLogger) Debug(args ...interface{})
- func (z *ZapLogger) Debugf(msg string, args ...interface{})
- func (z *ZapLogger) Debugw(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) Error(args ...interface{})
- func (z *ZapLogger) Errorf(msg string, args ...interface{})
- func (z *ZapLogger) Errorw(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) Fatal(args ...interface{})
- func (z *ZapLogger) Fatalf(msg string, args ...interface{})
- func (z *ZapLogger) Fatalw(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) Info(args ...interface{})
- func (z *ZapLogger) Infof(msg string, args ...interface{})
- func (z *ZapLogger) Infow(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) Named(name string) Logger
- func (z *ZapLogger) Panic(args ...interface{})
- func (z *ZapLogger) Panicf(msg string, args ...interface{})
- func (z *ZapLogger) Panicw(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) Warn(args ...interface{})
- func (z *ZapLogger) Warnf(msg string, args ...interface{})
- func (z *ZapLogger) Warnw(msg string, keysAndValues ...interface{})
- func (z *ZapLogger) With(field string, value interface{}) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureLogger ¶
EnsureLogger ensures that a logger is attached to the context. If one is not present, a new development logger is created and attached.
func Interceptor ¶
func Interceptor() grpc.UnaryServerInterceptor
Interceptor returns a GRPC Logging interceptor configured to log using the prefab logging adapter.
func Track ¶
Track a field across the lifetime of the context. Unlike GRPC's logging.InjectFields, tracked values will persist back up the call-chain to the logging interceptor. As such, do not use this as a convenience in loops, without creating a new scope using `logging.With(ctx, logger.Named("foo"))`.
Types ¶
type Logger ¶
type Logger interface {
Debug(args ...interface{})
Debugw(msg string, keysAndValues ...interface{})
Debugf(msg string, args ...interface{})
Info(args ...interface{})
Infow(msg string, keysAndValues ...interface{})
Infof(msg string, args ...interface{})
Warn(args ...interface{})
Warnw(msg string, keysAndValues ...interface{})
Warnf(msg string, args ...interface{})
Error(args ...interface{})
Errorw(msg string, keysAndValues ...interface{})
Errorf(msg string, args ...interface{})
Panic(args ...interface{})
Panicw(msg string, keysAndValues ...interface{})
Panicf(msg string, args ...interface{})
Fatal(args ...interface{})
Fatalw(msg string, keysAndValues ...interface{})
Fatalf(msg string, args ...interface{})
// Named creates a child logger with the given name.
Named(name string) Logger
// With creates a child logger and attaches structured cotnext to it.
With(field string, value interface{}) Logger
}
Logger provides an abstract logging interface designed around uber-go/zap's sugared logger, but is intended to provide interop with other libraries.
func FromContext ¶
FromContext returns a scoped logger.
func NewDevLogger ¶
func NewDevLogger() Logger
NewDevLogger returns a zap logger that prints dev friendly output.
func NewProdLogger ¶
func NewProdLogger() Logger
NewProdLogger returns a zap logger that outputs JSON.