log

package
v0.0.0-...-55a6e25 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextFieldDefault = "core"
View Source
var ContextFieldName = "ctx"
View Source
var ModeFieldName = "mode"

Functions

func Init

func Init(conf *Config)

Init should be called when the app starts, from a config object.

func SetLevel

func SetLevel(lv Level)

Types

type CodecometWriter

type CodecometWriter struct {
	// Out is the output destination.
	Out io.Writer

	// NoColor disables the colorized output.
	NoColor bool

	// TimeFormat specifies the format for timestamp in output.
	TimeFormat string

	// PartsOrder defines the order of parts in output.
	PartsOrder []string

	// PartsExclude defines parts to not display in output.
	PartsExclude []string

	// FieldsExclude defines contextual fields to not display in output.
	FieldsExclude []string

	FormatTimestamp     Formatter
	FormatLevel         Formatter
	FormatMessage       Formatter
	FormatContext       Formatter
	FormatMode          Formatter
	FormatFieldName     Formatter
	FormatFieldValue    Formatter
	FormatErrFieldName  Formatter
	FormatErrFieldValue Formatter

	FormatExtra func(map[string]interface{}, *bytes.Buffer) error
}

CodecometWriter parses the JSON input and writes it in an (optionally) colorized, human-friendly format to Out.

func NewCodecometWriter

func NewCodecometWriter(options ...func(w *CodecometWriter)) CodecometWriter

NewCodecometWriter creates and initializes a new CodecometWriter.

func (CodecometWriter) Write

func (w CodecometWriter) Write(p []byte) (n int, err error)

Write transforms the JSON input with formatters and appends to w.Out.

type Config

type Config struct {
	Level Level `json:"level,omitempty"`
}

type Event

type Event = zerolog.Event

func Debug

func Debug() *Event

func Error

func Error() *Event

func Fatal

func Fatal() *Event

func Info

func Info() *Event

func LoggerForLevel

func LoggerForLevel(level string) *Event

func Trace

func Trace() *Event

func Warn

func Warn() *Event

type Formatter

type Formatter func(interface{}) string

Formatter transforms the input into a formatted string.

type Level

type Level = zerolog.Level
const (
	// DebugLevel defines debug log level.
	DebugLevel Level = iota
	// InfoLevel defines info log level.
	InfoLevel
	// WarnLevel defines warn log level.
	WarnLevel
	// ErrorLevel defines error log level.
	ErrorLevel
	// FatalLevel defines fatal log level.
	FatalLevel
	// PanicLevel defines panic log level.
	PanicLevel
	// NoLevel defines an absent log level.
	NoLevel
	// Disabled disables the logger.
	Disabled

	// TraceLevel defines trace log level.
	TraceLevel Level = -1
)

func GetLevel

func GetLevel() Level

Jump to

Keyboard shortcuts

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