discard

package module
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 5 Imported by: 13

README

non-Logger for slog.Logger

Go Reference

The discard handler is a placeholder to avoid having to conditionally decide if using a logger or not. discard will handle Panic() and Fatal() correctly, but everything else will be discarded.

for Panic/Fatal messages, the Go standard logger will be called. fields and call stack are lost.

See also

Documentation

Overview

Package discard is a Logger that doesn't really log anything

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() slog.Logger

New creates a slog.Logger that doesn't really log anything

Types

type Logger

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

Logger implements slog.Logger but doesn't log anything

func (*Logger) Debug

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

Debug pretends to return a new NOOP logger

func (*Logger) Enabled

func (nl *Logger) Enabled() bool

Enabled tells that we only handle Fatal and Panic.

func (*Logger) Error

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

Error pretends to return a new NOOP logger

func (*Logger) Fatal

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

Fatal return a new Fatal logger

func (*Logger) Info

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

Info pretends to return a new NOOP logger

func (*Logger) Panic

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

Panic return a new Panic logger

func (*Logger) Print

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

Print pretends to add a log entry with arguments handled in the manner of fmt.Print

func (*Logger) Printf

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

Printf pretends to add a log entry with arguments handled in the manner of fmt.Printf

func (*Logger) Println

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

Println pretends to add a log entry with arguments handled in the manner of fmt.Println

func (*Logger) Warn

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

Warn pretends to return a new NOOP logger

func (*Logger) WithEnabled

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

WithEnabled passes the logger, but also indicates if it's enabled or not. This logger is only enabled for Fatal entries

func (*Logger) WithField

func (nl *Logger) WithField(string, any) slog.Logger

WithField pretends to add a fields to the Logger

func (*Logger) WithFields

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

WithFields pretends to add fields to the Logger

func (*Logger) WithLevel

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

WithLevel pretends to return a new logger set to add entries to the level.

func (*Logger) WithStack

func (nl *Logger) WithStack(int) slog.Logger

WithStack pretends to attach a call stack to the logger

Jump to

Keyboard shortcuts

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