logging

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package logging manages application logging using the log/slog package.

This package provides a structured logging facility for applications. It allows the creation of a Logger instance that can log messages at different severity levels such as Debug, Info, Warn, Error, and Fatal. The logging configuration is flexible and supports different output destinations (such as standard output or files) and formats (such as JSON or colored text).

The Logger uses the slog package for structured logging and can be configured to determine the logging output and format based on user-defined settings.

Use the New function to create a Logger instance with specified logging configuration. Various methods are provided to log messages at different severity levels with additional context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger represents an instance of the logging system.

func New

func New(config *config.LoggingConfig) *Logger

New creates a new Logger instance with the specified logging configuration.

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...any)

Debug logs a message at the debug level.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...any)

Error logs a message at the error level.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, args ...any)

Fatal simulates the behavior of a fatal log level.

func (*Logger) Info

func (l *Logger) Info(msg string, args ...any)

Info logs a message at the info level.

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...any)

Warn logs a message at the warn level.

Jump to

Keyboard shortcuts

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