logging

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Caller

func Caller(skip int) (file string, line int, fn string)

Caller returns information about the calling function

func Debug

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

Package-level convenience functions

func Error

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

func Fatal

func Fatal(msg string, args ...interface{})

func Info

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

func SetGlobalLogger

func SetGlobalLogger(l *Logger)

SetGlobalLogger sets the global logger

func Warn

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

Types

type Level

type Level int

Level represents a log level

const (
	// LevelDebug is for debug messages
	LevelDebug Level = iota
	// LevelInfo is for informational messages
	LevelInfo
	// LevelWarn is for warning messages
	LevelWarn
	// LevelError is for error messages
	LevelError
	// LevelFatal is for fatal messages
	LevelFatal
)

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a log level from string

func (Level) String

func (l Level) String() string

String returns the string representation of a log level

type Logger

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

Logger is a structured logger

func Default

func Default() *Logger

Default returns the default logger

func GetGlobalLogger

func GetGlobalLogger() *Logger

GetGlobalLogger returns the global logger

func New

func New(level Level) *Logger

New creates a new logger

func (*Logger) Debug

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

Debug logs a debug message

func (*Logger) Error

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

Error logs an error message

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, args ...interface{})

Fatal logs a fatal message and exits

func (*Logger) Info

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

Info logs an info message

func (*Logger) SetColorized

func (l *Logger) SetColorized(c bool)

SetColorized sets whether output should be colorized

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the log level

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

SetOutput sets the output writer

func (*Logger) Warn

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

Warn logs a warning message

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *Logger

WithField returns a new logger with the given field

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]interface{}) *Logger

WithFields returns a new logger with the given fields

func (*Logger) WithPrefix

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

WithPrefix returns a new logger with the given prefix

Jump to

Keyboard shortcuts

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