logs

package
v0.0.0-...-8340aad Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevel = 1
)

Variables

This section is empty.

Functions

func AuditLog

func AuditLog(ctx context.Context) logr.Logger

AuditLog returns logger prepared with audit markers

func InitDevelLoggers

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

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

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

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

func (l *HCLogAdapter) Clone() *HCLogAdapter

func (*HCLogAdapter) Debug

func (l *HCLogAdapter) Debug(msg string, args ...interface{})

Debug - emit a message and key/value pairs at the DEBUG level

func (*HCLogAdapter) Error

func (l *HCLogAdapter) Error(msg string, args ...interface{})

Error - emit a message and key/value pairs at the ERROR level

func (*HCLogAdapter) GetLevel

func (l *HCLogAdapter) GetLevel() hclog.Level

GetLevel has no implementation.

func (*HCLogAdapter) GetUnderlying

func (l *HCLogAdapter) GetUnderlying() *zap.Logger

func (*HCLogAdapter) ImpliedArgs

func (l *HCLogAdapter) ImpliedArgs() []interface{}

ImpliedArgs has no implementation.

func (*HCLogAdapter) Info

func (l *HCLogAdapter) Info(msg string, args ...interface{})

Info - emit a message and key/value pairs at the INFO level

func (*HCLogAdapter) IsDebug

func (l *HCLogAdapter) IsDebug() bool

func (*HCLogAdapter) IsError

func (l *HCLogAdapter) IsError() bool

func (*HCLogAdapter) IsInfo

func (l *HCLogAdapter) IsInfo() bool

func (*HCLogAdapter) IsTrace

func (l *HCLogAdapter) IsTrace() bool

func (*HCLogAdapter) IsWarn

func (l *HCLogAdapter) IsWarn() bool

func (*HCLogAdapter) Log

func (l *HCLogAdapter) Log(level hclog.Level, msg string, args ...interface{})

func (*HCLogAdapter) Name

func (l *HCLogAdapter) Name() string

Name returns a logger's name (if presented).

func (*HCLogAdapter) Named

func (l *HCLogAdapter) Named(name string) hclog.Logger

Named returns a logger with the specific name.

func (*HCLogAdapter) ResetNamed

func (l *HCLogAdapter) ResetNamed(name string) hclog.Logger

ResetNamed has the same implementation as Named.

func (*HCLogAdapter) SetLevel

func (l *HCLogAdapter) SetLevel(level hclog.Level)

SetLevel has no implementation.

func (*HCLogAdapter) StandardLogger

func (l *HCLogAdapter) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger

func (*HCLogAdapter) StandardWriter

func (l *HCLogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer

StandardWriter returns os.Stderr as io.Writer.

func (*HCLogAdapter) Trace

func (l *HCLogAdapter) Trace(msg string, args ...interface{})

Trace - emit a message and key/value pairs at the TRACE level

func (*HCLogAdapter) Warn

func (l *HCLogAdapter) Warn(msg string, args ...interface{})

Warn - emit a message and key/value pairs at the WARN level

func (*HCLogAdapter) With

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