log

package
v0.0.0-...-05bc493 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Disabled   = logcommon.Disabled
	DebugLevel = logcommon.DebugLevel
	InfoLevel  = logcommon.InfoLevel
	WarnLevel  = logcommon.WarnLevel
	ErrorLevel = logcommon.ErrorLevel
	FatalLevel = logcommon.FatalLevel
	PanicLevel = logcommon.PanicLevel
	NoLevel    = logcommon.NoLevel

	LevelCount = logcommon.LogLevelCount
)

NoLevel means it should be ignored

View Source
const DefaultOutputParallelLimit = 5
View Source
const MinLevel = logcommon.MinLevel

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level = logcommon.Level

func ParseLevel

func ParseLevel(levelStr string) (Level, error)

type Logger

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

A Logger represents an active logging object

func WrapEmbeddedLogger

func WrapEmbeddedLogger(embedded logcommon.EmbeddedLogger) Logger

WrapEmbeddedLogger returns initialized Logger for given embedded adapter

func (Logger) Copy

func (z Logger) Copy() LoggerBuilder

Copy returns a builder to create a new logger that inherits current settings.

func (Logger) Debug

func (z Logger) Debug(args ...interface{})

Debug logs an event with level Debug. When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Debugf

func (z Logger) Debugf(fmt string, args ...interface{})

Debugf logs an event with level Debug. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Debugm

func (z Logger) Debugm(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Debugm logs an event with level Debug. msg is expected to be logging struct, extra fields could be provided

func (Logger) Embeddable

func (z Logger) Embeddable() logcommon.EmbeddedLogger

Embeddable returns an internal representation of the logger. Do not use directly as caller handling may be incorrect.

func (Logger) Error

func (z Logger) Error(args ...interface{})

Error logs an event with level Error. When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Errorf

func (z Logger) Errorf(fmt string, args ...interface{})

Errorf logs an event with level Error. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Errorm

func (z Logger) Errorm(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Errorm logs an event with level Error. msg is expected to be logging struct, extra fields could be provided

func (Logger) Event

func (z Logger) Event(level Level, args ...interface{})

Event logs an event of the given (level). When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Eventf

func (z Logger) Eventf(level Level, fmt string, args ...interface{})

Eventf logs an event of the given (level). Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Eventm

func (z Logger) Eventm(level Level, msgStruct interface{}, fields ...logfmt.LogFieldMarshaller)

Events logs an event of the given (level). Value of (msgStruct) is processed as a logging struct. And the event will also include provided (fields).

func (Logger) Fatal

func (z Logger) Fatal(args ...interface{})

Fatal logs an event with level Fatal and calls os.Exit(1) after log message has been written When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Fatalf

func (z Logger) Fatalf(fmt string, args ...interface{})

Fatalf logs an event with level Fatal and calls os.Exit(1) after log message has been written. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Fatalm

func (z Logger) Fatalm(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Fatalm logs an event with level Fatal and calls os.Exit(1) after log message has been written. msg is expected to be logging struct, extra fields could be provided

func (Logger) FieldsOf

func (z Logger) FieldsOf(data interface{}) logfmt.LogFieldMarshaller

func (Logger) Info

func (z Logger) Info(args ...interface{})

Info logs an event with level Info. When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Infof

func (z Logger) Infof(fmt string, args ...interface{})

Infof logs an event with level Info. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Infom

func (z Logger) Infom(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Infom logs an event with level Info. msg is expected to be logging struct, extra fields could be provided

func (Logger) Is

func (z Logger) Is(level Level) bool

Is returns true when the given level will reach the output

func (Logger) IsZero

func (z Logger) IsZero() bool

IsZero returns true if logger has been initialized with non zero embedded

func (Logger) Panic

func (z Logger) Panic(args ...interface{})

Panic logs an event with level Panic and calls panic after log message has been written When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Panicf

func (z Logger) Panicf(fmt string, args ...interface{})

Panicf logs an event with level Panic and calls panic after log message has been written. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Panicm

func (z Logger) Panicm(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Panicm logs an event with level Panic and calls panic after log message has been written. msg is expected to be logging struct, extra fields could be provided

func (Logger) Warn

func (z Logger) Warn(args ...interface{})

Warn logs an event with level Warn. When a single argument is provided - the argument is evaluated as a logging struct. Multiple arguments or single non-record argument are formatted into a string by MsgFormatConfig.Sformat()

func (Logger) Warnf

func (z Logger) Warnf(fmt string, args ...interface{})

Warnf logs an event with level Warn. Argument(s) are formatted into a string by MsgFormatConfig.Sformatf()

func (Logger) Warnm

func (z Logger) Warnm(msg interface{}, fields ...logfmt.LogFieldMarshaller)

Warnm logs an event with level Warn. msg is expected to be logging struct, extra fields could be provided

func (Logger) WithField

func (z Logger) WithField(name string, value interface{}) Logger

WithField add a fields for to-be-built logger. Fields are deduplicated within a single builder only.

func (Logger) WithFields

func (z Logger) WithFields(fields map[string]interface{}) Logger

WithFields adds fields for to-be-built logger. Fields are deduplicated within a single builder only.

type LoggerBuilder

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

LoggerBuilder is used to build new Logger with extra persistent and dynamic fields. It ensures layer of abstraction between logger itself, extra fields storage and writer

func NewBuilder

func NewBuilder(factory logcommon.Factory, config logcommon.Config, level Level) LoggerBuilder

NewBuilder returns new LoggerBuilder with given factory

func NewBuilderWithTemplate

func NewBuilderWithTemplate(template logcommon.Template, level Level) LoggerBuilder

NewBuilderWithTemplate returns new LoggerBuilder from given template

func (LoggerBuilder) Build

func (z LoggerBuilder) Build() (Logger, error)

Build creates a logger.

func (LoggerBuilder) BuildLowLatency

func (z LoggerBuilder) BuildLowLatency() (Logger, error)

BuildLowLatency creates a logger with no write delays.

func (LoggerBuilder) GetFormat

func (z LoggerBuilder) GetFormat() logcommon.LogFormat

func (LoggerBuilder) GetLogLevel

func (z LoggerBuilder) GetLogLevel() Level

GetLogLevel returns the current log level

func (LoggerBuilder) GetOutput

func (z LoggerBuilder) GetOutput() io.Writer

GetOutput returns the current output destination/writer

func (LoggerBuilder) IsZero

func (z LoggerBuilder) IsZero() bool

IsZero returns true if logger has valid factory

func (LoggerBuilder) MustBuild

func (z LoggerBuilder) MustBuild() Logger

MustBuild creates a logger. Panics on error.

func (LoggerBuilder) WithBuffer

func (z LoggerBuilder) WithBuffer(bufferSize int, bufferForAll bool) LoggerBuilder

WithBuffer sets buffer size and applicability of the buffer. Will be IGNORED when a reused output is already buffered.

func (LoggerBuilder) WithCaller

Controls 'func' and 'caller' field computation. See also WithSkipFrameCount().

func (LoggerBuilder) WithDynamicField

func (z LoggerBuilder) WithDynamicField(k string, fn logcommon.DynFieldFunc) LoggerBuilder

Adds a dynamically-evaluated field. Fields are deduplicated. When func=nil or func()=nil then the field is omitted.

func (LoggerBuilder) WithField

func (z LoggerBuilder) WithField(k string, v interface{}) LoggerBuilder

WithField add a fields for to-be-built logger. Fields are deduplicated within a single builder only.

func (LoggerBuilder) WithFields

func (z LoggerBuilder) WithFields(fields map[string]interface{}) LoggerBuilder

WithFields adds fields for to-be-built logger. Fields are deduplicated within a single builder only.

func (LoggerBuilder) WithFormat

func (z LoggerBuilder) WithFormat(format logcommon.LogFormat) LoggerBuilder

WithFormat sets logger output format. Format support depends on the log adapter. Unsupported format will fail on Build(). NB! Changing log format may clear out inherited non-dynamic fields (depends on adapter). NB! Format can be ignored when WithOutput(LoggerOutput) is applied (depends on adapter).

func (LoggerBuilder) WithLevel

func (z LoggerBuilder) WithLevel(level Level) LoggerBuilder

WithLevel sets log level.

func (LoggerBuilder) WithMetrics

Controls collection of metrics. Required flags are ADDED to the current flags. Include specify LogMetricsResetMode to replace flags.

func (LoggerBuilder) WithMetricsRecorder

func (z LoggerBuilder) WithMetricsRecorder(recorder logcommon.LogMetricsRecorder) LoggerBuilder

WithMetricsRecorder sets an custom recorder for metric collection.

func (LoggerBuilder) WithOutput

func (z LoggerBuilder) WithOutput(w io.Writer) LoggerBuilder

WithOutput sets the output destination/writer for the logger. Argument of LoggerOutput type will allow fine-grain control of events, but it may ignore WithFormat (depends on adapter).

func (LoggerBuilder) WithSkipFrameCount

func (z LoggerBuilder) WithSkipFrameCount(skipFrameCount int) LoggerBuilder

WithSkipFrameCount allows customization of skip frames for 'func' and 'caller' fields.

func (LoggerBuilder) WithoutInheritedDynFields

func (z LoggerBuilder) WithoutInheritedDynFields() LoggerBuilder

WithoutInheritedDynFields clears out inherited dynamic fields only

func (LoggerBuilder) WithoutInheritedFields

func (z LoggerBuilder) WithoutInheritedFields() LoggerBuilder

WithoutInheritedFields clears out inherited fields (dynamic or not)

type Msg

type Msg = logfmt.MsgTemplate

Jump to

Keyboard shortcuts

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