logging

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalLogger = NewLogger(zerolog.Disabled, false, nil)

GlobalLogger describes a Logger that is disabled by default and is instantiated when the fuzzer is created. Each module/package should create its own sub-logger. This allows to create unique logging instances depending on the use case.

Functions

This section is empty.

Types

type LogBuffer

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

LogBuffer is a helper object that can be used to buffer log messages. A log buffer is effectively a list of arguments of any type. This object is especially useful when attempting to log complex objects (e.g. execution trace) that have complex coloring schemes and formatting. The LogBuffer can then be passed on to a Logger object to then log the buffer to console and any other writers (e.g. file).

func NewLogBuffer

func NewLogBuffer() *LogBuffer

NewLogBuffer creates a new LogBuffer object

func (*LogBuffer) Append

func (l *LogBuffer) Append(newElements ...any)

Append appends a variadic set of elements to the list of elements

func (*LogBuffer) Elements

func (l *LogBuffer) Elements() []any

Elements returns the list of elements stored in this LogBuffer

func (LogBuffer) String

func (l LogBuffer) String() string

String provides the non-colorized string representation of the LogBuffer

type LogFormat

type LogFormat string

LogFormat describes what format to log in

const (
	// STRUCTURED describes that logging should be done in structured JSON format
	STRUCTURED LogFormat = "structured"
	// UNSTRUCTRED describes that logging should be done in an unstructured format
	UNSTRUCTURED LogFormat = "unstructured"
)

type Logger

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

Logger describes a custom logging object that can log events to any arbitrary channel and can handle specialized output to console as well

func NewLogger

func NewLogger(level zerolog.Level, consoleEnabled bool, writers ...io.Writer) *Logger

NewLogger will create a new Logger object with a specific log level. The Logger can output to console, if enabled, and output logs to any number of arbitrary io.Writer channels

func (*Logger) AddWriter

func (l *Logger) AddWriter(writer io.Writer, format LogFormat)

AddWriter will add a writer to the list of channels where log output will be sent.

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

Debug is a wrapper function that will log a debug event

func (*Logger) Error

func (l *Logger) Error(args ...any)

Error is a wrapper function that will log an error event.

func (*Logger) Info

func (l *Logger) Info(args ...any)

Info is a wrapper function that will log an info event

func (*Logger) Level

func (l *Logger) Level() zerolog.Level

Level will get the log level of the Logger

func (*Logger) NewSubLogger

func (l *Logger) NewSubLogger(key string, value string) *Logger

NewSubLogger will create a new Logger with unique context in the form of a key-value pair. The expected use of this function is for each package to have their own unique logger so that parsing of logs is "grep-able" based on some key

func (*Logger) Panic

func (l *Logger) Panic(args ...any)

Panic is a wrapper function that will log a panic event

func (*Logger) RemoveWriter

func (l *Logger) RemoveWriter(writer io.Writer)

RemoveWriter will remove a writer from the list of writers that the logger manages. If the writer does not exist, this function is a no-op

func (*Logger) SetLevel

func (l *Logger) SetLevel(level zerolog.Level)

SetLevel will update the log level of the Logger

func (*Logger) Trace

func (l *Logger) Trace(args ...any)

Trace is a wrapper function that will log a trace event

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

Warn is a wrapper function that will log a warning event both on console

type StructuredLogInfo

type StructuredLogInfo map[string]any

StructuredLogInfo describes a key-value mapping that can be used to log structured data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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