logging

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int32

Level defines the log severity levels.

const (
	Debug Level = iota
	Info
	Warn
	Error
	Fatal
)

Enumeration of log levels from least to most severe.

func (Level) String

func (l Level) String() string

String provides a string representation of the logging level.

type Logger

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

Logger represents the logging structure with configurable options.

func NewLogger

func NewLogger(opts ...Option) (*Logger, error)

NewLogger creates a new :ogger instance with the provided options. If no options are provided, default values are used.

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

Debug logs a debug message with the given arguments.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

Debugf logs a formatted debug message.

func (*Logger) Error

func (l *Logger) Error(args ...any)

Error logs an error message.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

Errorf logs a formatted error message.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...any)

Fatal logs a fatal error message and then terminates the program.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...any)

Fatalf logs a formatted fatal error message and then terminates the program.

func (*Logger) Info

func (l *Logger) Info(args ...any)

Info logs an informational message.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

Infof logs a formatted informational message.

func (*Logger) Warn

func (l *Logger) Warn(args ...any)

Warn logs a warning message.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

Warnf logs a formatted warning message.

type Option

type Option func(options *options) error

func WithFlag

func WithFlag(flag int) Option

WithFlag sets the flags used by the logger.

func WithLevel

func WithLevel(level Level) Option

WithLevel sets the level of the logger.

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix sets the prefix for the log.ger

func WithWriter

func WithWriter(w io.Writer) Option

WithWriter sets the writer that will be used by the logger.

Jump to

Keyboard shortcuts

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