logging

package
v0.0.0-...-6e6de49 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: Apache-2.0 Imports: 1 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// Print the level information of the final message, if requested
	PartOrderLevel = 0x0

	// Print the timestamp information of the final message, if requested
	PartOrderTimestamp = 0x1

	// Print the level correlation id of the final message, if requested
	PartOrderCorrelationId = 0x2

	// Print the level information of the final message. Always printed
	PartOrderMessage = 0x3

	// Print the level information of the final message, only if there is one extra parameter
	PartOrderExtra = 0x4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ExtraParametersFormat ExtraParametersFormatCallback
	CustomLogFormat       CustomLogFormatCallback
	CustomTime            CustomTimeCallback
	Level                 Level
	TimeFormat            string
	ExtraParametersPrefix string
	Order                 []PartOrder

	SkipPrintLevel           bool
	SkipPrintCorrelationID   bool
	SkipPrintTimestamp       bool
	SkipExtraParameterPrefix bool
}

LoggerConfig is the configuration of the logger behavior

type Context

type Context interface {
	CorrID() string
	Extras() []K
	Clone() Context
	CloneNoExtra() Context
	AddExtra(extra ...K)
}

Context contains all context information for a log message plus extra arguments

type CustomLogFormatCallback

type CustomLogFormatCallback func(CustomLogFormatData) string

CustomLogFormatCallback defines the format of the final message

type CustomLogFormatData

type CustomLogFormatData struct {
	Level         Level
	Message       string
	CurrentTime   time.Time
	CorrelationID string
	ExtraParams   []K
}

CustomLogFormatData defines input parameters used to format a log message

type CustomTimeCallback

type CustomTimeCallback func() (string, time.Time)

CustomTimeCallback defines the time value written to the final message

type ExtraParametersFormatCallback

type ExtraParametersFormatCallback func([]K) string

ExtraParametersFormatCallback defines the format of the string conversion of the parameter in K struct format

type Factory

type Factory interface {
	Create() Logger
	CreateFromConfig(Config) Logger
}

LoggerFactory defines the behavior of the factory used to generate logging from a template at runtime

type K

type K struct {
	N string
	V interface{}
}

K is used to define a log message ctx parameter, using Name/Value form

type Level

type Level uint

Level defines the level type

const (
	// Error level
	Error Level = 0

	// Warn level
	Warn Level = 1

	// Info level
	Info Level = 2

	// Debug level
	Debug Level = 3

	// Trace level
	Trace Level = 4
)

type Logger

type Logger interface {
	Info(ctx Context, msg string, params ...interface{})
	Debug(ctx Context, msg string, params ...interface{})
	Trace(ctx Context, msg string, params ...interface{})
	Error(ctx Context, msg string, params ...interface{})
	Warn(ctx Context, msg string, params ...interface{})

	BeginMethod(ctx Context)
	BeginMethodParams(ctx Context, format string, params ...interface{})
	EndMethod(ctx Context)
	EndMethodParams(ctx Context, format string, params ...interface{})
}

Logger abstract the selected log backend

type PartOrder

type PartOrder uint

Defines new type for the list of message items.

Directories

Path Synopsis
base module

Jump to

Keyboard shortcuts

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