logger

package
v0.0.0-...-f767cfc Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package logger provides Logger, which is a wrapper around zerolog.Logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsoleWriter

type ConsoleWriter struct {
	Out        io.Writer // Out is the destination writer for log messages.
	NoColor    bool      // NoColor disables ANSI color escape codes in output.
	TimeFormat string    // TimeFormat is the format for timestamps in output.
	// contains filtered or unexported fields
}

ConsoleWriter is a console writer for Logger that writes log messages to the console in a user-friendly format.

func NewConsoleWriter

func NewConsoleWriter(options ...func(w *ConsoleWriter)) *ConsoleWriter

NewConsoleWriter creates a new ConsoleWriter with the specified options.

func (ConsoleWriter) Write

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

Write implements the io.Writer interface.

type Context

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

Context configures a new sub-logger with contextual fields.

func (Context) Caller

func (c Context) Caller() Context

Caller adds the file:line of the caller with the zerolog.CallerFieldName key.

func (Context) Logger

func (c Context) Logger() Logger

Logger returns the logger with the context previously set.

func (Context) Timestamp

func (c Context) Timestamp() Context

Timestamp adds the current local time as UNIX timestamp to the logger context with the "time" key. To customize the key name, change zerolog.TimestampFieldName.

type Logger

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

Logger provides a structured and leveled logging interface using zerolog.Logger.

func NewLogger

func NewLogger(w io.Writer) Logger

NewLogger creates a new Logger instance that writes to the specified io.Writer.

func (Logger) Debug

func (l Logger) Debug(v ...any)

Debug logs a message at the Debug severity level.

func (Logger) DebugFields

func (l Logger) DebugFields(msg string, fields map[string]any)

DebugFields logs a message with associated fields at the Debug severity level.

func (Logger) Debugf

func (l Logger) Debugf(format string, v ...any)

Debugf logs a message at the Debug severity level.

func (Logger) Error

func (l Logger) Error(v ...any)

Error logs a message at the Error severity level.

func (Logger) ErrorFields

func (l Logger) ErrorFields(msg string, fields map[string]any)

ErrorFields logs a message with associated fields at the Error severity level.

func (Logger) Errorf

func (l Logger) Errorf(format string, v ...any)

Errorf logs a message at the Error severity level.

func (Logger) Fatal

func (l Logger) Fatal(v ...any)

Fatal logs a message at the Fatal severity level.

func (Logger) FatalFields

func (l Logger) FatalFields(msg string, fields map[string]any)

FatalFields logs a message with associated fields at the Fatal severity level.

func (Logger) Fatalf

func (l Logger) Fatalf(format string, v ...any)

Fatalf logs a message at the Fatal severity level.

func (Logger) Info

func (l Logger) Info(v ...any)

Info logs a message at the Info severity level.

func (Logger) InfoFields

func (l Logger) InfoFields(msg string, fields map[string]any)

InfoFields logs a message with associated fields at the Info severity level.

func (Logger) Infof

func (l Logger) Infof(format string, v ...any)

Infof logs a message at the Info severity level.

func (Logger) Panic

func (l Logger) Panic(v ...any)

Panic logs a message at the Panic severity level.

func (Logger) PanicFields

func (l Logger) PanicFields(msg string, fields map[string]any)

PanicFields logs a message with associated fields at the Panic severity level.

func (Logger) Panicf

func (l Logger) Panicf(format string, v ...any)

Panicf logs a message at the Panic severity level.

func (Logger) Trace

func (l Logger) Trace(v ...any)

Trace logs a message at the Trace severity level.

func (Logger) TraceFields

func (l Logger) TraceFields(msg string, fields map[string]any)

TraceFields logs a message with associated fields at the Trace severity level.

func (Logger) Tracef

func (l Logger) Tracef(format string, v ...any)

Tracef logs a message at the Trace severity level.

func (Logger) Warn

func (l Logger) Warn(v ...any)

Warn logs a message at the Warn severity level.

func (Logger) WarnFields

func (l Logger) WarnFields(msg string, fields map[string]any)

WarnFields logs a message with associated fields at the Warn severity level.

func (Logger) Warnf

func (l Logger) Warnf(format string, v ...any)

Warnf logs a message at the Warn severity level.

func (Logger) With

func (l Logger) With() Context

With creates a child logger with the field added to its context.

Jump to

Keyboard shortcuts

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