logfc

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtLevel

func AtLevel(ctx context.Context, level logf.Level, fn func(logf.LogFunc))

AtLevel calls the given fn if logging a message at the specified level is enabled, passing a logf.LogFunc with the bound level or does nothing if there is no logf.Logger associated with ctx.

func Debug

func Debug(ctx context.Context, text string, fs ...logf.Field)

Debug logs a debug message with the given text, optional fields and fields passed to the logf.Logger using With function or logs nothing if no logf.Logger is associated with ctx.

func Error

func Error(ctx context.Context, text string, fs ...logf.Field)

Error logs an error message with the given text, optional fields and fields passed to the logf.Logger using With function or logs nothing if no logf.Logger is associated with ctx.

func Get

func Get(ctx context.Context) *logf.Logger

Get returns the logf.Logger associated with ctx or log.DisabledLogger() if no value is associated. Successive calls to Get return the same result.

func Info

func Info(ctx context.Context, text string, fs ...logf.Field)

Info logs an info message with the given text, optional fields and fields passed to the logf.Logger using With function or logs nothing if no logf.Logger is associated with ctx.

func MustAtLevel

func MustAtLevel(ctx context.Context, level logf.Level, fn func(logf.LogFunc))

MustAtLevel calls the given fn if logging a message at the specified level is enabled, passing a logf.LogFunc with the bound level or panics if there is no logf.Logger associated with ctx.

func MustDebug

func MustDebug(ctx context.Context, text string, fs ...logf.Field)

MustDebug logs a debug message with the given text, optional fields and fields passed to the logf.Logger using With function or panics if no logf.Logger is associated with ctx.

func MustError

func MustError(ctx context.Context, text string, fs ...logf.Field)

MustError logs an error message with the given text, optional fields and fields passed to the logf.Logger using With function or panics if no logf.Logger is associated with ctx.

func MustGet

func MustGet(ctx context.Context) *logf.Logger

MustGet returns the logf.Logger associated with ctx or panics if no value is associated. Successive calls to MustGet return the same result.

func MustInfo

func MustInfo(ctx context.Context, text string, fs ...logf.Field)

MustInfo logs an info message with the given text, optional fields and fields passed to the logf.Logger using With function or panics if no logf.Logger is associated with ctx.

func MustWarn

func MustWarn(ctx context.Context, text string, fs ...logf.Field)

MustWarn logs a warning message with the given text, optional fields and fields passed to the logf.Logger using With function or panics if no logf.Logger is associated with ctx.

func MustWith

func MustWith(ctx context.Context, fields ...logf.Field) context.Context

MustWith returns a new context.Context with provided fields appended to fields of logf.Logger associated with ctx or panics if no logf.Logger is associated with ctx.

func MustWithCaller

func MustWithCaller(ctx context.Context) context.Context

MustWithCaller returns a new context.Context with a logf.Logger that adds a special annotation parameters to each logging message, such as the filename and line number of a caller or panics if no logf.Logger is associated with ctx.

func MustWithCallerSkip

func MustWithCallerSkip(ctx context.Context, n int) context.Context

MustWithCallerSkip returns a new context.Context with a logf.Logger that adds a special annotation parameters with additional n skipped frames to each logging message, such as the filename and line number of a caller or panics if no logf.Logger is associated with ctx.

func MustWithLevel added in v1.4.2

func MustWithLevel(ctx context.Context, level logf.LevelCheckerGetter) context.Context

MustWithLevel returns a new context.Context with a new logf.Logger with the given additional level checker. MustWithLevel panics if no logf.Logger is associated with ctx. Name separator is a period.

func MustWithName

func MustWithName(ctx context.Context, name string) context.Context

MustWithName returns a new context.Context with a new logf.Logger adding the given name to the original one or panics if no logf.Logger is associated with ctx. Name separator is a period.

func New

func New(parent context.Context, logger *logf.Logger) context.Context

New returns a new context.Context with the given logger associated with it.

Note: the given logger will hide any other logger which was associated with this context before.

func Warn

func Warn(ctx context.Context, text string, fs ...logf.Field)

Warn logs a warning message with the given text, optional fields and fields passed to the logf.Logger using With function or logs nothing if no logf.Logger is associated with ctx.

func With

func With(ctx context.Context, fields ...logf.Field) context.Context

With returns a new context.Context with new logf.Logger inside with provided fields appended to current logf.Logger associated with ctx If there is no logf.Logger is associated with ctx, logf.DisabledLogger() is used as a base logger.

func WithCaller

func WithCaller(ctx context.Context) context.Context

WithCaller returns a new context.Context with a new logf.Logger that adds a special annotation parameters to each logging message, such as the filename and line number of a caller. If there is no logf.Logger is associated with ctx, logf.DisabledLogger() is used as a base logger.

func WithCallerSkip

func WithCallerSkip(ctx context.Context, n int) context.Context

WithCallerSkip returns a new context.Context with a new logf.Logger that adds a special annotation parameters with additional n skipped frames to each logging message, such as the filename and line number of a caller. If there is no logf.Logger is associated with ctx, logf.DisabledLogger() is used as a base logger.

func WithLevel added in v1.4.1

func WithLevel(ctx context.Context, level logf.LevelCheckerGetter) context.Context

WithLevel returns a new context.Context with a new logf.Logger with the given additional level checker. If there is no logf.Logger is associated with ctx, logf.DisabledLogger() is used as a base logger.

func WithName

func WithName(ctx context.Context, name string) context.Context

WithName returns a new context.Context with a new logf.Logger adding the given name to the original one. If there is no logf.Logger is associated with ctx, logf.DisabledLogger() is used as a base logger. Name separator is a period.

Types

This section is empty.

Jump to

Keyboard shortcuts

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