logs

package
v0.2023.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DebugLevel = 1
)

Variables

This section is empty.

Functions

func AuditLog added in v0.2023.21

func AuditLog(ctx context.Context) logr.Logger

AuditLog returns logger prepared with audit markers

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

func TimeTrack(log logr.Logger, start time.Time, name string)

TimeTrack used to time any function Example:

{
  defer logs.TimeTrack(lg, time.Now(), "fetch all github repositories")
}

func TimeTrackWithLazyLogger added in v0.9.0

func TimeTrackWithLazyLogger(loggerGetter func() logr.Logger, start time.Time, name string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL