logger

package
v0.0.0-...-75ec8e3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(format string, args ...interface{})

Debug logs a debug message using the global logger

func Error

func Error(format string, args ...interface{})

Error logs an error message using the global logger

func Info

func Info(format string, args ...interface{})

Info logs an informational message using the global logger

func Init

func Init(level Level, logPath string) error

Init initializes the global logger

func InitWithConsole

func InitWithConsole(level Level, logPath string, enableConsole bool) error

InitWithConsole initializes the global logger with optional console output

func NewSlogHandler

func NewSlogHandler(l *Logger) slog.Handler

NewSlogHandler returns a slog.Handler that forwards records to the provided Logger. If logger is nil, it returns nil.

func Warn

func Warn(format string, args ...interface{})

Warn logs a warning message using the global logger

Types

type Level

type Level int

Level represents a logging level

const (
	// LevelDebug is the most verbose logging level
	LevelDebug Level = iota
	// LevelInfo logs informational messages
	LevelInfo
	// LevelWarn logs warnings
	LevelWarn
	// LevelError logs errors
	LevelError
	// LevelNone disables all logging
	LevelNone
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a string into a Level

func (Level) String

func (l Level) String() string

String returns string representation of log level

type Logger

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

Logger provides structured logging capabilities

func Global

func Global() *Logger

Global returns the global logger instance

func New

func New(level Level, logPath string, prefix string) (*Logger, error)

New creates a new Logger instance

func NewWithConsole

func NewWithConsole(level Level, logPath string, prefix string, enableConsole bool) (*Logger, error)

NewWithConsole creates a new Logger instance with optional console output

func (*Logger) Close

func (l *Logger) Close() error

Close closes the logger and its underlying file

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug logs a debug message

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error logs an error message

func (*Logger) GetLevel

func (l *Logger) GetLevel() Level

GetLevel returns the current logging level

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info logs an informational message

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the logging level

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn logs a warning message

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(prefix string) *Logger

WithPrefix creates a new logger with an additional prefix

Jump to

Keyboard shortcuts

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