logging

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogger = NewStructuredLogger()

Default logger instance

Functions

func Debug

func Debug(message string)

Package-level convenience functions

func Error

func Error(message string)

func Fatal

func Fatal(message string)

func Info

func Info(message string)

func Warn

func Warn(message string)

Types

type JobLogger

type JobLogger struct {
	*StructuredLogger
	// contains filtered or unexported fields
}

JobLogger provides job-specific logging

func NewJobLogger

func NewJobLogger(jobID, jobName string) *JobLogger

NewJobLogger creates a logger for a specific job

func (*JobLogger) LogComplete

func (jl *JobLogger) LogComplete(duration time.Duration, success bool)

LogComplete logs job completion

func (*JobLogger) LogError

func (jl *JobLogger) LogError(err error, context string)

LogError logs an error with context

func (*JobLogger) LogProgress

func (jl *JobLogger) LogProgress(message string, percentComplete float64)

LogProgress logs job progress

func (*JobLogger) LogRetry

func (jl *JobLogger) LogRetry(attempt int, maxAttempts int, err error)

LogRetry logs a retry attempt

func (*JobLogger) LogStart

func (jl *JobLogger) LogStart()

LogStart logs job start

func (*JobLogger) SetMetricsCollector

func (jl *JobLogger) SetMetricsCollector(metrics MetricsCollector)

SetMetricsCollector sets the metrics collector for the job logger

type LogEntry

type LogEntry struct {
	Timestamp     time.Time              `json:"timestamp"`
	Level         string                 `json:"level"`
	Message       string                 `json:"message"`
	Fields        map[string]interface{} `json:"fields,omitempty"`
	Caller        string                 `json:"caller,omitempty"`
	StackTrace    string                 `json:"stackTrace,omitempty"`
	CorrelationID string                 `json:"correlationId,omitempty"`
}

LogEntry represents a structured log entry

type LogLevel

type LogLevel int

LogLevel represents the severity of a log message

const (
	DebugLevel LogLevel = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

func (LogLevel) String

func (l LogLevel) String() string

type MetricsCollector

type MetricsCollector interface {
	IncrementCounter(name string, value float64)
	SetGauge(name string, value float64)
	ObserveHistogram(name string, value float64)
}

MetricsCollector interface for logging metrics integration

type StructuredLogger

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

StructuredLogger provides structured logging capabilities

func NewStructuredLogger

func NewStructuredLogger() *StructuredLogger

NewStructuredLogger creates a new structured logger

func (*StructuredLogger) Debug

func (l *StructuredLogger) Debug(message string)

Debug logs a debug message

func (*StructuredLogger) DebugWithFields

func (l *StructuredLogger) DebugWithFields(message string, fields map[string]interface{})

DebugWithFields logs a debug message with fields

func (*StructuredLogger) Debugf

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

Debugf logs a formatted debug message

func (*StructuredLogger) Error

func (l *StructuredLogger) Error(message string)

Error logs an error message

func (*StructuredLogger) ErrorWithFields

func (l *StructuredLogger) ErrorWithFields(message string, fields map[string]interface{})

ErrorWithFields logs an error message with fields

func (*StructuredLogger) Errorf

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

Errorf logs a formatted error message

func (*StructuredLogger) Fatal

func (l *StructuredLogger) Fatal(message string)

Fatal logs a fatal message. Note: Does not exit automatically. Caller should handle the fatal condition appropriately.

func (*StructuredLogger) FatalWithFields

func (l *StructuredLogger) FatalWithFields(message string, fields map[string]interface{})

FatalWithFields logs a fatal message with fields. Note: Does not exit automatically. Caller should handle the fatal condition appropriately.

func (*StructuredLogger) Fatalf

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

Fatalf logs a formatted fatal message. Note: Does not exit automatically. Caller should handle the fatal condition appropriately.

func (*StructuredLogger) Info

func (l *StructuredLogger) Info(message string)

Info logs an info message

func (*StructuredLogger) InfoWithFields

func (l *StructuredLogger) InfoWithFields(message string, fields map[string]interface{})

InfoWithFields logs an info message with fields

func (*StructuredLogger) Infof

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

Infof logs a formatted info message

func (*StructuredLogger) SetJSONFormat

func (l *StructuredLogger) SetJSONFormat(enabled bool)

SetJSONFormat enables/disables JSON formatting

func (*StructuredLogger) SetLevel

func (l *StructuredLogger) SetLevel(level LogLevel)

SetLevel sets the minimum log level

func (*StructuredLogger) SetOutput

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

SetOutput sets the output writer

func (*StructuredLogger) Warn

func (l *StructuredLogger) Warn(message string)

Warn logs a warning message

func (*StructuredLogger) WarnWithFields

func (l *StructuredLogger) WarnWithFields(message string, fields map[string]interface{})

WarnWithFields logs a warning message with fields

func (*StructuredLogger) Warnf

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

Warnf logs a formatted warning message

func (*StructuredLogger) WithCorrelationID

func (l *StructuredLogger) WithCorrelationID(id string) *StructuredLogger

WithCorrelationID sets a correlation ID for tracing

func (*StructuredLogger) WithField

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

WithField creates a new logger with an additional field

func (*StructuredLogger) WithFields

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

WithFields creates a new logger with additional fields

Jump to

Keyboard shortcuts

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