logger

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DestinationUndefined = ""
	DestinationStdout    = "stdout"
	DestinationJournald  = "journald"
)

Variables

This section is empty.

Functions

func UpdateLevelForTags added in v0.45.0

func UpdateLevelForTags(prm Prm)

Types

type LogMetrics added in v0.38.0

type LogMetrics interface {
	Inc(level zapcore.Level, dropped bool)
	GetSamplingHook() func(e zapcore.Entry, sd zapcore.SamplingDecision)
}

func NewLogMetrics added in v0.38.0

func NewLogMetrics(namespace string) LogMetrics

type Logger

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

Logger represents a component for writing messages to log.

func NewLogger

func NewLogger(prm Prm) (*Logger, error)

NewLogger constructs a new zap logger instance. Constructing with nil parameters is safe: default values will be used then. Passing non-nil parameters after a successful creation (non-error) allows runtime reconfiguration.

Logger is built from production logging configuration with:

  • parameterized level;
  • console encoding;
  • ISO8601 time encoding.

Logger records a stack trace for all messages at or above fatal level.

func NewLoggerWrapper added in v0.44.0

func NewLoggerWrapper(z *zap.Logger) *Logger

func (*Logger) Debug added in v0.44.0

func (l *Logger) Debug(ctx context.Context, msg string, fields ...zap.Field)

func (*Logger) Error added in v0.44.0

func (l *Logger) Error(ctx context.Context, msg string, fields ...zap.Field)

func (*Logger) Info added in v0.44.0

func (l *Logger) Info(ctx context.Context, msg string, fields ...zap.Field)

func (*Logger) Warn added in v0.44.0

func (l *Logger) Warn(ctx context.Context, msg string, fields ...zap.Field)

func (*Logger) With added in v0.44.0

func (l *Logger) With(fields ...zap.Field) *Logger

With create a child logger with new fields, don't affect the parent. Throws panic if tag is unset.

func (*Logger) WithTag added in v0.45.0

func (l *Logger) WithTag(tag Tag) *Logger

WithTag is an equivalent of calling NewLogger with the same parameters for the current logger. Throws panic if provided unsupported tag.

type Prm

type Prm struct {

	// SamplingHook hook for the zap.Logger
	SamplingHook func(e zapcore.Entry, sd zapcore.SamplingDecision)

	// PrependTimestamp specifies whether to prepend a timestamp in the log
	PrependTimestamp bool

	// Options for zap.Logger
	Options []zap.Option
	// contains filtered or unexported fields
}

Prm groups Logger's parameters. Successful passing non-nil parameters to the NewLogger (if returned error is nil) connects the parameters with the returned Logger. Parameters that have been connected to the Logger support its configuration changing.

See also Logger.Reload, SetLevelString.

func (*Prm) SetDestination added in v0.38.0

func (p *Prm) SetDestination(d string) error

func (*Prm) SetLevelString

func (p *Prm) SetLevelString(s string) error

SetLevelString sets the minimum logging level. Default is "info".

Returns an error if s is not a string representation of a supporting logging level.

Supports runtime rereading.

func (*Prm) SetTags added in v0.45.0

func (p *Prm) SetTags(tags [][]string) (err error)

SetTags parses list of tags with log level.

type Tag added in v0.45.0

type Tag uint8
const (
	TagMain            Tag // main
	TagMorph               // morph
	TagGrpcSvc             // grpcsvc
	TagIr                  // ir
	TagProcessor           // processor
	TagEngine              // engine
	TagBlobovnicza         // blobovnicza
	TagBlobovniczaTree     // blobovniczatree
	TagBlobstor            // blobstor
	TagFSTree              // fstree
	TagGC                  // gc
	TagShard               // shard
	TagWriteCache          // writecache
	TagMetabase            // metabase
	TagDeleteSvc           // deletesvc
	TagGetSvc              // getsvc
	TagPutSvc              // putsvc
	TagSearchSvc           // searchsvc
	TagSessionSvc          // sessionsvc
	TagTreeSvc             // treesvc
	TagPolicer             // policer
	TagReplicator          // replicator
	TagAPESvc              // apesvc
	TagAuditSvc            // auditsvc
	TagQos                 // qos

)

func (Tag) String added in v0.45.0

func (i Tag) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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