xlogger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Msgf

func Msgf(msg string, args ...any) string

Types

type Logger

type Logger interface {
	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Trace("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Trace(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Trace("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Trace(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Debug("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Debug(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Debug("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Debug(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Info("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Info(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Info("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Info(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Warn("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Warn(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Warn("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Warn(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Error("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Error(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Error("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Error(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Fatal("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Fatal(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Fatal("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Fatal(msg string, fields ...any)

	/*
		Fields is a helper function to use a map or slice to set fields using type assertion.
		[]any must alternate string keys and arbitrary values, and extraneous ones are ignored. i.e:

		With Request HTTP Context:

			first := "first value"
			second := "second value"
			xlogger.FromReqCtx(ctx).Panic("hello", "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Panic(xlogger.Msgf("hello %s", "world!"), "first", first, "second", second)
			xlogger.FromReqCtx(ctx).Panic("oh snap! got error", "error", fmt.Sprint("%+v", err))
	*/
	Panic(msg string, fields ...any)
}

func FromReqCtx

func FromReqCtx(ctx context.Context) Logger

func NewZeroLogger

func NewZeroLogger(log *zerolog.Logger) Logger

type ZeroLogger

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

func (*ZeroLogger) Debug

func (zl *ZeroLogger) Debug(msg string, fields ...any)

func (*ZeroLogger) Error

func (zl *ZeroLogger) Error(msg string, fields ...any)

func (*ZeroLogger) Fatal

func (zl *ZeroLogger) Fatal(msg string, fields ...any)

func (*ZeroLogger) Info

func (zl *ZeroLogger) Info(msg string, fields ...any)

func (*ZeroLogger) Panic

func (zl *ZeroLogger) Panic(msg string, fields ...any)

func (*ZeroLogger) Trace

func (zl *ZeroLogger) Trace(msg string, fields ...any)

func (*ZeroLogger) Warn

func (zl *ZeroLogger) Warn(msg string, fields ...any)

Jump to

Keyboard shortcuts

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