Documentation
¶
Index ¶
- Variables
- func DeregisterDefaultWriteHook(key string) stackerr.Error
- func GetAwsLogger() logging.Logger
- func InitDefault(input NewInput) stackerr.Error
- func LogContext(ctx context.Context, logger Logger) context.Context
- func RegisterDefaultWriteHook(key string, hook ZapWriteHook) stackerr.Error
- func SweetenDefaultLogger(fields map[string]any) stackerr.Error
- func SweetenDefaultLoggerForLambda(ctx context.Context, fields map[string]any) stackerr.Error
- func UnsweetenDefaultLogger(fieldKeys []string) stackerr.Error
- type DynamicDefaultLogger
- type Logger
- type NewInput
- type StackError
- type ZapWriteHook
Constants ¶
This section is empty.
Variables ¶
var DebugInterface func(args ...interface{})
var Debugf func(template string, args ...interface{})
var Debugw func(msg string, keysAndValues ...interface{})
var Error func(err error)
var ErrorInterface func(args ...interface{})
var Errorf func(template string, args ...interface{})
var Errorw func(msg string, keysAndValues ...interface{})
var Fatal func(err error)
var FatalInterface func(args ...interface{})
var Fatalf func(template string, args ...interface{})
var Fatalw func(msg string, keysAndValues ...interface{})
var InfoInterface func(args ...interface{})
var Infof func(template string, args ...interface{})
var Infow func(msg string, keysAndValues ...interface{})
var Panic func(err error)
var PanicInterface func(args ...interface{})
var Panicf func(template string, args ...interface{})
var Panicw func(msg string, keysAndValues ...interface{})
var WarnInterface func(args ...interface{})
var Warnf func(template string, args ...interface{})
var Warnw func(msg string, keysAndValues ...interface{})
var With func(args ...interface{}) Logger
var WithError func(err error) Logger
var WithOptions func(opts ...zap.Option) Logger
var WithStackTrace func(stack stackerr.Stack, useAsCaller bool) Logger
Functions ¶
func DeregisterDefaultWriteHook ¶
func DeregisterDefaultWriteHook(key string) stackerr.Error
func GetAwsLogger ¶
func InitDefault ¶
func InitDefault(input NewInput) stackerr.Error
InitDefault will create a new logger with the given settings and will set it as the default global logger. This function IS NOT thread-safe and cannot be used while other routines are using the existing global default logger.
func LogContext ¶
LogContext will return a new context with the given logger added to the given context.
func RegisterDefaultWriteHook ¶
func RegisterDefaultWriteHook(key string, hook ZapWriteHook) stackerr.Error
func SweetenDefaultLogger ¶
SweetenDefaultLogger will add fields to the default logger.
func SweetenDefaultLoggerForLambda ¶
SweetenDefaultLoggerForLambda will add Lambda metadata fields (request ID and logs URL) to the default logger, as well as any additional fields in the `fields` parameter. If this is not executed within a Lambda function, nothing will be added.
func UnsweetenDefaultLogger ¶
func UnsweetenDefaultLogger(fieldKeys []string) stackerr.Error
UnsweetenDefaultLogger will remove fields from the default logger.
Types ¶
type DynamicDefaultLogger ¶
func NewDynamicDefaultLogger ¶
func NewDynamicDefaultLogger(loggerConfigFunc func(input NewInput) NewInput) DynamicDefaultLogger
type Logger ¶
type Logger interface { Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) Fatalf(template string, args ...interface{}) Panicf(template string, args ...interface{}) Debugw(msg string, keysAndValues ...interface{}) Infow(msg string, keysAndValues ...interface{}) Warnw(msg string, keysAndValues ...interface{}) Errorw(msg string, keysAndValues ...interface{}) Fatalw(msg string, keysAndValues ...interface{}) Panicw(msg string, keysAndValues ...interface{}) DebugInterface(args ...interface{}) InfoInterface(args ...interface{}) WarnInterface(args ...interface{}) ErrorInterface(args ...interface{}) FatalInterface(args ...interface{}) PanicInterface(args ...interface{}) Error(err error) Panic(err error) Fatal(err error) With(args ...interface{}) Logger WithOptions(opts ...zap.Option) Logger WithError(err error) Logger WithStackTrace(stack stackerr.Stack, useAsCaller bool) Logger // WithAdditionalSkippedFrames will return a new logger that skips additional // frames when finding the caller and the stack trace. WithAdditionalSkippedFrames(skippedFrames int) Logger // RegisterWriteHook will register a function hook that will be called // for each log write. RegisterWriteHook(key string, hook ZapWriteHook) stackerr.Error // DergisterWriteHook will deregister a hook that was registered with RegisterWriteHook DergisterWriteHook(key string) stackerr.Error // Config gets the config values that can be used to re-create this logger Config() NewInput // Clone returns a copy of the logger Clone() Logger }
func FromContext ¶
FromContext will extract a logger from a context if it contains one, or return the default logger if it doesn't.