zerolog

package module
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 7 Imported by: 3

README

slog.Logger adapter for zerolog

Go Reference

This package implements a wrapper around a *zerolog.Logger so it can be used as a slog.Logger.

See also

Documentation

Overview

Package zerolog provides a slog.Logger adaptor using a github.com/rs/zerolog Logger as backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(logger *zerolog.Logger) slog.Logger

New creates a slog.Logger adaptor using a zerolog as backend, if one was passed.

Types

type Logger

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

Logger is an adaptor for using github.com/rs/zerolog as slog.Logger.

func (*Logger) Debug

func (zl *Logger) Debug() slog.Logger

Debug returns a new Event Context set to add entries as level Debug.

func (*Logger) Enabled

func (zl *Logger) Enabled() bool

Enabled tells if the underlying logger is enabled or not.

func (*Logger) Error

func (zl *Logger) Error() slog.Logger

Error returns a new Event Context set to add entries as level Error.

func (*Logger) Fatal

func (zl *Logger) Fatal() slog.Logger

Fatal returns a new Event Context set to add entries as level Fatal.

func (*Logger) Info

func (zl *Logger) Info() slog.Logger

Info returns a new Event Context set to add entries as level Info.

func (*Logger) NewWithCallback

func (zl *Logger) NewWithCallback(fn func(ev *zerolog.Event)) *Logger

NewWithCallback creates a new zerolog.Event using a callback to modify it.

func (*Logger) Panic

func (zl *Logger) Panic() slog.Logger

Panic returns a new Event Context set to add entries as level Panic.

func (*Logger) Print

func (zl *Logger) Print(args ...any)

Print adds a log entry with arguments handled in the manner of fmt.Print.

func (*Logger) Printf

func (zl *Logger) Printf(format string, args ...any)

Printf adds a log entry with arguments handled in the manner of fmt.Printf.

func (*Logger) Println

func (zl *Logger) Println(args ...any)

Println adds a log entry with arguments handled in the manner of fmt.Println.

func (*Logger) Warn

func (zl *Logger) Warn() slog.Logger

Warn returns a new Event Context set to add entries as level Warn.

func (*Logger) WithEnabled

func (zl *Logger) WithEnabled() (slog.Logger, bool)

WithEnabled tells if the logger would log or not

func (*Logger) WithField

func (zl *Logger) WithField(label string, value any) slog.Logger

WithField adds a field to the Event Context

func (*Logger) WithFields

func (zl *Logger) WithFields(fields map[string]any) slog.Logger

WithFields adds fields to the Event Context

func (*Logger) WithLevel

func (zl *Logger) WithLevel(level slog.LogLevel) slog.Logger

WithLevel returns a new Event Context set to add entries to the specified level.

func (*Logger) WithStack

func (zl *Logger) WithStack(skip int) slog.Logger

WithStack attaches a call stack to the Event Context

Jump to

Keyboard shortcuts

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