logging

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 8 Imported by: 0

README

go-mergeSort

Wrapper for <github.com/rs/zerolog>

Documentation

Overview

Package logging contains project logging functions

Index

Constants

View Source
const (
	// ModuleFieldName is tag for module name in log output
	ModuleFieldName = "module"
	// FileFieldName is tag for file name in log output
	FileFieldName = "file"
	// PackageFieldName is tag for package name in log output
	PackageFieldName = "package"
	// FuncFieldName is tag for func name in log output
	FuncFieldName = "func"
	// DefaultTimeFormat is time format
	DefaultTimeFormat = "2006-01-02 15:04:05.000"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CallerHook

type CallerHook struct{}

CallerHook is caller hook structure

func (CallerHook) Run

func (h CallerHook) Run(event *zerolog.Event, _ zerolog.Level, _ string)

Run is caller hook for add some fields for every logging call

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Warning(args ...interface{})
	Warningf(format string, args ...interface{})

	// Structured logging methods, use to add context fields
	String(key, value string) Logger
	Int(key string, value int) Logger
	Int64(key string, value int64) Logger
	Interface(key string, value interface{}) Logger
	Bytes(key string, value []byte) Logger
	Fields(fields map[string]interface{}) Logger

	// Get child logger with the minimum accepted level
	Level(string) (Logger, error)
	// Returns new copy of log, when need to avoid context duplication
	Clone() Logger
}

Logger implements logger abstraction.

func GetLogger

func GetLogger(module string) (Logger, error)

GetLogger need only for backward compatibility in tests

type ZLogger

type ZLogger struct {
	zerolog.Logger
}

ZLogger is implementation of zerolog logger

func ConfigureLog

func ConfigureLog(logFile, logLevel, module string, pretty bool) (*ZLogger, error)

ConfigureLog creates new logger based on github.com/rs/zerolog package

func (*ZLogger) Bytes

func (l *ZLogger) Bytes(key string, value []byte) Logger

Bytes adding bytes value to log output

func (ZLogger) Clone

func (l ZLogger) Clone() Logger

Clone clones Zlogger structure

func (ZLogger) Debug

func (l ZLogger) Debug(args ...interface{})

Debug prints message for debug level

func (ZLogger) Debugf

func (l ZLogger) Debugf(format string, args ...interface{})

Debugf prints message for debug level

func (ZLogger) Error

func (l ZLogger) Error(args ...interface{})

Error prints message for error level

func (ZLogger) Errorf

func (l ZLogger) Errorf(format string, args ...interface{})

Errorf prints message for error level

func (ZLogger) Fatal

func (l ZLogger) Fatal(args ...interface{})

Fatal prints message for fatal level

func (ZLogger) Fatalf

func (l ZLogger) Fatalf(format string, args ...interface{})

Fatalf prints message for fatal level

func (*ZLogger) Fields

func (l *ZLogger) Fields(fields map[string]interface{}) Logger

Fields adding fields map to log output

func (ZLogger) Info

func (l ZLogger) Info(args ...interface{})

Info prints message for info level

func (ZLogger) Infof

func (l ZLogger) Infof(format string, args ...interface{})

Infof prints message for info level

func (*ZLogger) Int

func (l *ZLogger) Int(key string, value int) Logger

Int adding int value to log output

func (*ZLogger) Int64

func (l *ZLogger) Int64(key string, value int64) Logger

Int64 adding int64 value to log output

func (*ZLogger) Interface

func (l *ZLogger) Interface(key string, value interface{}) Logger

Interface adding interface value to log output

func (*ZLogger) Level

func (l *ZLogger) Level(s string) (Logger, error)

Level set logging level for logger

func (*ZLogger) String

func (l *ZLogger) String(key, value string) Logger

String adding string value to log output

func (ZLogger) Warning

func (l ZLogger) Warning(args ...interface{})

Warning prints message for warning level

func (ZLogger) Warningf

func (l ZLogger) Warningf(format string, args ...interface{})

Warningf prints message for warning level

Jump to

Keyboard shortcuts

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