logging

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const NamespaceKey = "namespace"

Variables

This section is empty.

Functions

func DefaultHandler

func DefaultHandler(params Parameters) slog.Handler

DefaultHandler creates a new slog handler with the specified parameters.

func Error

func Error(err error) slog.Attr

func LoggerTypeStrings

func LoggerTypeStrings() []string

LoggerTypeStrings returns a slice of all String values of the enum

func NewHandler

func NewHandler(loggerType LoggerType, level slog.Level) slog.Handler

NewHandler creates a new slog handler based on the specified logger type and level.

func TxID

func TxID(t txIDGetter, scheme scheme) slog.Attr

func Type

func Type(value any) slog.Attr

Type returns a slog.Attr that contains the type name of the value.

Types

type LoggerType

type LoggerType int

LoggerType is a type of logger output. Possible types:

  • LoggerText: The standard slog.TextHandler.
  • LoggerJSON: The standard slog.JSONHandler.
  • LoggerPretty: The logger outputs pretty messages.
  • LoggerPrettyNoColor: The logger outputs pretty messages without colors.
  • LoggerTextDev: The standard slog.TextHandler with error traces and source code location output.
  • LoggerJSONDev: The standard slog.JSONHandler with error traces and source code location output.
  • LoggerPrettyDev: The logger outputs pretty messages with error traces and source code location output.
  • LoggerPrettyNoColorDev: The logger outputs pretty messages without colors with error traces and source code location output.
const (
	LoggerText LoggerType = iota
	LoggerJSON
	LoggerPretty
	LoggerPrettyNoColor
	LoggerTextDev
	LoggerJSONDev
	LoggerPrettyDev
	LoggerPrettyNoColorDev
)

func LoggerTypeString

func LoggerTypeString(s string) (LoggerType, error)

LoggerTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LoggerTypeValues

func LoggerTypeValues() []LoggerType

LoggerTypeValues returns all values of the enum

func (LoggerType) IsALoggerType

func (i LoggerType) IsALoggerType() bool

IsALoggerType returns "true" if the value is listed in the enum definition. "false" otherwise

func (LoggerType) MarshalText

func (i LoggerType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for LoggerType

func (LoggerType) String

func (i LoggerType) String() string

func (*LoggerType) UnmarshalText

func (i *LoggerType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for LoggerType

type Parameters

type Parameters struct {
	Level slog.Level
	Type  LoggerType
	// contains filtered or unexported fields
}

func (*Parameters) Initialize

func (p *Parameters) Initialize()

Initialize adds logging command line parameters to the global flag set.

func (*Parameters) Parse

func (p *Parameters) Parse() error

Parse parses the command line parameters for logging.

func (*Parameters) String

func (p *Parameters) String() string

Jump to

Keyboard shortcuts

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