logger

package
v0.0.0-...-ba04163 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset        = "\033[0m"
	ColorRed          = "\033[31m"
	ColorYellow       = "\033[33m"
	ColorBlue         = "\033[34m"
	ColorGray         = "\033[37m"
	ColorGreen        = "\033[32m"
	ColorCyan         = "\033[36m"
	ColorBrightRed    = "\033[91m"
	ColorBrightYellow = "\033[93m"
	ColorBrightBlue   = "\033[94m"
	ColorBrightGray   = "\033[90m"
)

ANSI color codes for console output

View Source
const (
	ServiceNameWidth = 20 // Fixed width for service names
	LogLevelWidth    = 7  // Fixed width for log levels (ERROR, WARN, etc.) - icons add +2
)

Column widths for better alignment (same as supervisor)

Variables

This section is empty.

Functions

func MapLogLevel

func MapLogLevel(level string) commonv1.LogLevel

MapLogLevel maps string log level to proto enum

Types

type LogContext

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

LogContext provides field-based logging

func (*LogContext) Error

func (c *LogContext) Error(message string)

func (*LogContext) Info

func (c *LogContext) Info(message string)

type LogEntry

type LogEntry struct {
	Time    time.Time
	Level   string
	Message string
	Fields  map[string]string
	TraceID string
}

LogEntry represents a single log entry

type Logger

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

Logger provides structured logging with streaming support

func New

func New(serviceName, version string) *Logger

New creates a new logger instance

func (*Logger) Debug

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

Debug logs a debug message with optional formatting

func (*Logger) Debugf

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

Debugf logs a formatted debug message

func (*Logger) DisableConsoleOutput

func (l *Logger) DisableConsoleOutput()

DisableConsoleOutput disables console output when streaming to supervisor

func (*Logger) EnableConsoleOutput

func (l *Logger) EnableConsoleOutput()

EnableConsoleOutput enables console output (default behavior)

func (*Logger) Error

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

Error logs an error message with optional formatting

func (*Logger) Errorf

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

Errorf logs a formatted error message

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

Fatal logs a fatal message and exits

func (*Logger) Fatalf

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

Fatalf logs a formatted fatal message and exits

func (*Logger) Info

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

Info logs an info message with optional formatting

func (*Logger) Infof

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

Infof logs a formatted info message

func (*Logger) Rotate

func (l *Logger) Rotate()

Rotate performs log rotation

func (*Logger) Subscribe

func (l *Logger) Subscribe() <-chan LogEntry

Subscribe returns a channel to receive log entries

func (*Logger) Warn

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

Warn logs a warning message with optional formatting

func (*Logger) Warnf

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

Warnf logs a formatted warning message

func (*Logger) WithFields

func (l *Logger) WithFields(fields map[string]string) *LogContext

WithFields logs a message with additional fields

Jump to

Keyboard shortcuts

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