Documentation ¶
Index ¶
- func GetRecentEscalatedLogs(c context.Context) []zapcore.Entry
- func GetRecentLogs(c context.Context) []zapcore.Entry
- func L(c context.Context) (l *zap.Logger)
- func LogError(c context.Context, err error)
- func S(c context.Context) *zap.SugaredLogger
- func UseLogger(c context.Context, l *zap.Logger) context.Context
- func WithLogger(c context.Context, cfg *zap.Config, fn func(context.Context) error) (err error)
- type MemoryLogger
- type VerbosityFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRecentEscalatedLogs ¶
GetRecentEscalatedLogs returns a list of recent buffered warn and error logs.
func GetRecentLogs ¶
GetRecentLogs returns a list of recent buffered logs.
func L ¶
L returns the logger embedded in rhe Context by WithLogger.
If there is no logger, L will panic.
func S ¶
func S(c context.Context) *zap.SugaredLogger
S is shorthand for L(c).Sugar().
Like L, if there is no logger, S will panic.
Types ¶
type MemoryLogger ¶
type MemoryLogger struct { // Size is the number of log entries to retain. Size int // Level is the minimum log level to retain. MinLevel zapcore.Level // contains filtered or unexported fields }
MemoryLogger integrates as a zap Logger hook which retains the last set of logs.
MemoryLogger's fields may not be adjusted after it has been installed as a hook.
Internally, MemoryLogger uses a ring buffer.
func (*MemoryLogger) Get ¶
func (ml *MemoryLogger) Get() []zapcore.Entry
Get returns the active entries.
type VerbosityFlag ¶
type VerbosityFlag struct { // Level is the underlying zapcore.Level variable to write to. *zapcore.Level }
VerbosityFlag is a pflag.Value wrapper around a zapcore.Level, allowing it to be used as a pflag.Value.
zapcore.Level provides flag.Value interface, so we only need to augment it.
func (*VerbosityFlag) Type ¶
func (vf *VerbosityFlag) Type() string
Type implements cobra's "pflag.Value" interface.