logger

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogLevel

func SetLogLevel(level LogLevel)

func SetLogOutput

func SetLogOutput(w io.Writer)

Types

type ILogger

type ILogger interface {
	Trace(msg string)
	Debug(msg string)
	Info(msg string)
	Warn(msg string)
	Error(msg string)
	Fatal(msg string)
	Tracef(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

type LogLevel

type LogLevel int32
const (
	LevelTrace LogLevel = iota
	LevelDebug
	LevelInfo
	LevelWarning
	LevelError
	LevelFatal
	LevelAudit
)

func (LogLevel) String

func (l LogLevel) String() string

type LogWriter

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

LogWriter wraps an io.Writer to maintain type consistency with atomic.Value

func (LogWriter) Write

func (lw LogWriter) Write(p []byte) (n int, err error)

type Logger

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

Logger handles all logging operations

func DefaultLogger

func DefaultLogger() *Logger

func NewLoggerWithLevelAndOutput

func NewLoggerWithLevelAndOutput(level LogLevel, w io.Writer) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Fatalf

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

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Infof

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

func (*Logger) LogOnce

func (l *Logger) LogOnce(msg string)

LogOnce Add a message to the log only once.

func (*Logger) LogOncef

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

LogOncef Add a formatted version of the thing.

func (*Logger) StructuredDebug

func (l *Logger) StructuredDebug(msg string, data map[string]any)

func (*Logger) StructuredError

func (l *Logger) StructuredError(msg string, data map[string]any)

func (*Logger) StructuredInfo

func (l *Logger) StructuredInfo(msg string, data map[string]any)

StructuredInfo is a Convenience methods for structured logging

func (*Logger) StructuredLog

func (l *Logger) StructuredLog(level LogLevel, msg string, data map[string]any)

func (*Logger) Trace

func (l *Logger) Trace(msg string)

func (*Logger) Tracef

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

Tracef is a Formatted versions of our logging methods

func (*Logger) Warn

func (l *Logger) Warn(msg string)

func (*Logger) Warnf

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

type StructuredLogEntry

type StructuredLogEntry struct {
	Timestamp time.Time      `json:"timestamp"`
	Level     string         `json:"level"`
	Message   string         `json:"message"`
	Data      map[string]any `json:"data,omitempty"`
	Caller    string         `json:"caller,omitempty"`
}

Jump to

Keyboard shortcuts

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