logger

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(message string, fields ...map[string]interface{})

Debug logs a debug message using the global logger

func Error

func Error(message string, fields ...map[string]interface{})

Error logs an error message using the global logger

func Fatal

func Fatal(message string, fields ...map[string]interface{})

Fatal logs a fatal message using the global logger and exits

func Info

func Info(message string, fields ...map[string]interface{})

Info logs an info message using the global logger

func SetGlobalLevel

func SetGlobalLevel(level Level)

SetGlobalLevel sets the global logger level

func Warn

func Warn(message string, fields ...map[string]interface{})

Warn logs a warning message using the global logger

Types

type Level

type Level int

Level represents the logging level

const (
	// DEBUG level
	DEBUG Level = iota
	// INFO level
	INFO
	// WARN level
	WARN
	// ERROR level
	ERROR
	// FATAL level
	FATAL
)

func (Level) String

func (l Level) String() string

String returns the string representation of the level

type LogEntry

type LogEntry struct {
	Timestamp string                 `json:"timestamp"`
	Level     string                 `json:"level"`
	Message   string                 `json:"message"`
	Service   string                 `json:"service"`
	Function  string                 `json:"function,omitempty"`
	File      string                 `json:"file,omitempty"`
	Line      int                    `json:"line,omitempty"`
	Fields    map[string]interface{} `json:"fields,omitempty"`
}

LogEntry represents a structured log entry

type Logger

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

Logger represents a structured logger

func NewLogger

func NewLogger(level Level) *Logger

NewLogger creates a new logger with the specified level

func NewLoggerWithWriter

func NewLoggerWithWriter(level Level, writer io.Writer) *Logger

NewLoggerWithWriter creates a new logger with a custom writer

func (*Logger) Debug

func (l *Logger) Debug(message string, fields ...map[string]interface{})

Debug logs a debug message

func (*Logger) Error

func (l *Logger) Error(message string, fields ...map[string]interface{})

Error logs an error message

func (*Logger) Fatal

func (l *Logger) Fatal(message string, fields ...map[string]interface{})

Fatal logs a fatal message and exits

func (*Logger) Info

func (l *Logger) Info(message string, fields ...map[string]interface{})

Info logs an info message

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the logging level

func (*Logger) Warn

func (l *Logger) Warn(message string, fields ...map[string]interface{})

Warn logs a warning message

func (*Logger) WithFields

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

WithFields returns a logger with additional fields

type LoggerWithFields

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

LoggerWithFields represents a logger with predefined fields

func (*LoggerWithFields) Debug

func (l *LoggerWithFields) Debug(message string, fields ...map[string]interface{})

Debug logs a debug message with predefined fields

func (*LoggerWithFields) Error

func (l *LoggerWithFields) Error(message string, fields ...map[string]interface{})

Error logs an error message with predefined fields

func (*LoggerWithFields) Fatal

func (l *LoggerWithFields) Fatal(message string, fields ...map[string]interface{})

Fatal logs a fatal message with predefined fields and exits

func (*LoggerWithFields) Info

func (l *LoggerWithFields) Info(message string, fields ...map[string]interface{})

Info logs an info message with predefined fields

func (*LoggerWithFields) Warn

func (l *LoggerWithFields) Warn(message string, fields ...map[string]interface{})

Warn logs a warning message with predefined fields

Jump to

Keyboard shortcuts

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