Documentation ¶
Index ¶
- Constants
- func AuditLog(ctx context.Context) logr.Logger
- func InitDevelLoggers()
- func InitLoggers(development bool, encoder string, logLevel string, stackTraceLevel string, ...)
- func TimeTrack(log logr.Logger, start time.Time, name string)
- func TimeTrackWithLazyLogger(loggerGetter func() logr.Logger, start time.Time, name string)
- type HCLogAdapter
- func (l *HCLogAdapter) Clone() *HCLogAdapter
- func (l *HCLogAdapter) Debug(msg string, args ...interface{})
- func (l *HCLogAdapter) Error(msg string, args ...interface{})
- func (l *HCLogAdapter) GetLevel() hclog.Level
- func (l *HCLogAdapter) GetUnderlying() *zap.Logger
- func (l *HCLogAdapter) ImpliedArgs() []interface{}
- func (l *HCLogAdapter) Info(msg string, args ...interface{})
- func (l *HCLogAdapter) IsDebug() bool
- func (l *HCLogAdapter) IsError() bool
- func (l *HCLogAdapter) IsInfo() bool
- func (l *HCLogAdapter) IsTrace() bool
- func (l *HCLogAdapter) IsWarn() bool
- func (l *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})
- func (l *HCLogAdapter) Name() string
- func (l *HCLogAdapter) Named(name string) hclog.Logger
- func (l *HCLogAdapter) ResetNamed(name string) hclog.Logger
- func (l *HCLogAdapter) SetLevel(level hclog.Level)
- func (l *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
- func (l *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
- func (l *HCLogAdapter) Trace(msg string, args ...interface{})
- func (l *HCLogAdapter) Warn(msg string, args ...interface{})
- func (l *HCLogAdapter) With(args ...interface{}) hclog.Logger
Constants ¶
const (
DebugLevel = 1
)
Variables ¶
This section is empty.
Functions ¶
func InitDevelLoggers ¶ added in v0.6.9
func InitDevelLoggers()
InitDevelLoggers Configure zap backend development logger
func InitLoggers ¶
func InitLoggers(development bool, encoder string, logLevel string, stackTraceLevel string, timeEncoding string)
InitLoggers Configure zap backend for controller-runtime logger.
func TimeTrack ¶
TimeTrack used to time any function Example:
{ defer logs.TimeTrack(lg, time.Now(), "fetch all github repositories") }
func TimeTrackWithLazyLogger ¶ added in v0.9.0
TimeTrackWithLazyLogger is very similar to TimeTrack. The only difference is that it obtains the logger lazily which enables the caller to use the logger instance as assigned at the very end of the function being tracked. Example:
{ lg := log.FromContext(ctx) defer logs.TimeTrackWithLazyLogger(func() logr.Logger {return lg}, time.Now(), "this is hard work, man!") lg = lg.WithValues("work", "really hard") ... }
The log message produced by the time tracker will contain the "work" => "really hard" key-value pair.
Types ¶
type HCLogAdapter ¶ added in v0.6.9
type HCLogAdapter struct {
// contains filtered or unexported fields
}
HCLogAdapter is an adapter that allows to use a zap.Logger where and hclog.Logger is expected.
func NewHCLogAdapter ¶ added in v0.6.9
func NewHCLogAdapter(wrapped *zap.Logger) *HCLogAdapter
NewHCLogAdapter creates a new adapter, wrapping an underlying zap.Logger inside an implementation that emulates hclog.Logger.
func (*HCLogAdapter) Clone ¶ added in v0.6.9
func (l *HCLogAdapter) Clone() *HCLogAdapter
func (*HCLogAdapter) Debug ¶ added in v0.6.9
func (l *HCLogAdapter) Debug(msg string, args ...interface{})
Debug - emit a message and key/value pairs at the DEBUG level
func (*HCLogAdapter) Error ¶ added in v0.6.9
func (l *HCLogAdapter) Error(msg string, args ...interface{})
Error - emit a message and key/value pairs at the ERROR level
func (*HCLogAdapter) GetLevel ¶ added in v0.2023.21
func (l *HCLogAdapter) GetLevel() hclog.Level
GetLevel has no implementation.
func (*HCLogAdapter) GetUnderlying ¶ added in v0.6.9
func (l *HCLogAdapter) GetUnderlying() *zap.Logger
func (*HCLogAdapter) ImpliedArgs ¶ added in v0.6.9
func (l *HCLogAdapter) ImpliedArgs() []interface{}
ImpliedArgs has no implementation.
func (*HCLogAdapter) Info ¶ added in v0.6.9
func (l *HCLogAdapter) Info(msg string, args ...interface{})
Info - emit a message and key/value pairs at the INFO level
func (*HCLogAdapter) IsDebug ¶ added in v0.6.9
func (l *HCLogAdapter) IsDebug() bool
func (*HCLogAdapter) IsError ¶ added in v0.6.9
func (l *HCLogAdapter) IsError() bool
func (*HCLogAdapter) IsInfo ¶ added in v0.6.9
func (l *HCLogAdapter) IsInfo() bool
func (*HCLogAdapter) IsTrace ¶ added in v0.6.9
func (l *HCLogAdapter) IsTrace() bool
func (*HCLogAdapter) IsWarn ¶ added in v0.6.9
func (l *HCLogAdapter) IsWarn() bool
func (*HCLogAdapter) Log ¶ added in v0.6.9
func (l *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})
func (*HCLogAdapter) Name ¶ added in v0.6.9
func (l *HCLogAdapter) Name() string
Name returns a logger's name (if presented).
func (*HCLogAdapter) Named ¶ added in v0.6.9
func (l *HCLogAdapter) Named(name string) hclog.Logger
Named returns a logger with the specific name.
func (*HCLogAdapter) ResetNamed ¶ added in v0.6.9
func (l *HCLogAdapter) ResetNamed(name string) hclog.Logger
ResetNamed has the same implementation as Named.
func (*HCLogAdapter) SetLevel ¶ added in v0.6.9
func (l *HCLogAdapter) SetLevel(level hclog.Level)
SetLevel has no implementation.
func (*HCLogAdapter) StandardLogger ¶ added in v0.6.9
func (l *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger
func (*HCLogAdapter) StandardWriter ¶ added in v0.6.9
func (l *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer
StandardWriter returns os.Stderr as io.Writer.
func (*HCLogAdapter) Trace ¶ added in v0.6.9
func (l *HCLogAdapter) Trace(msg string, args ...interface{})
Trace - emit a message and key/value pairs at the TRACE level
func (*HCLogAdapter) Warn ¶ added in v0.6.9
func (l *HCLogAdapter) Warn(msg string, args ...interface{})
Warn - emit a message and key/value pairs at the WARN level
func (*HCLogAdapter) With ¶ added in v0.6.9
func (l *HCLogAdapter) With(args ...interface{}) hclog.Logger
With returns a logger with always-presented key-value pairs.