internal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller struct {
	// File is the basename of the file for this call site.
	File string `json:"file"`
	// Line is the line number in the file for this call site.
	Line int `json:"line"`
	// Func is the function name for this call site, or empty if
	// Options.LogCallerFunc is not enabled.
	Func string `json:"function,omitempty"`
}

Caller represents the original call site for a log line, after considering logr.Logger.WithCallDepth and logr.Logger.WithCallStackHelper. The File and Line fields will always be provided, while the Func field is optional.

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

func NewFormatter

func NewFormatter(opts Options) Formatter

NewFormatter returns a constructed Formatter.

func (*Formatter) AddCallDepth

func (f *Formatter) AddCallDepth(depth int)

AddCallDepth increases the number of stack-frames to skip when attributing the log line to a file and line.

func (*Formatter) AddContext

func (f *Formatter) AddContext(ctx context.Context)

AddContext adds log values for the span in ctx if it exists.

func (*Formatter) AddName

func (f *Formatter) AddName(name string)

AddName appends the specified name.

func (*Formatter) AddValues

func (f *Formatter) AddValues(kvList []interface{})

func (Formatter) FormatError

func (f Formatter) FormatError(err error, msg string, kvList []interface{}) *lpb.LogRecord

func (Formatter) FormatInfo

func (f Formatter) FormatInfo(level int, msg string, kvList []interface{}) *lpb.LogRecord

func (Formatter) FormatResource

func (f Formatter) FormatResource(res *resource.Resource) (string, *rpb.Resource)

func (Formatter) FormatScope

func (*Formatter) Init

func (f *Formatter) Init(info logr.RuntimeInfo)

Init configures this Formatter from runtime info, such as the call depth imposed by logr itself.

type MessageClass

type MessageClass int

MessageClass indicates which category or categories of messages to consider.

const (
	// None ignores all message classes.
	None MessageClass = iota
	// All considers all message classes.
	All
	// Info only considers info messages.
	Info
	// Error only considers error messages.
	Error
)

type Options

type Options struct {
	// LogCaller defines when to add a "caller" key to some or all log lines.
	// This has some overhead, so some users might not want it.
	LogCaller MessageClass

	// LogCallerFunc defines if the calling function name shoule be logged.
	// This has no effect if caller logging is not enabled (see
	// Options.LogCaller).
	LogCallerFunc bool

	// MaxLogDepth defines how many levels of nested fields (e.g. a struct that
	// contains a struct, etc.) to log. If this field is not specified, a
	// default value, 16, will be used.
	MaxLogDepth int
}

Jump to

Keyboard shortcuts

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