logger

package
v0.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldRequestID = "request_id"
	FieldUserID    = "user_id"
	FieldOrgID     = "org_id"
	FieldClusterID = "cluster_id"
	FieldStackID   = "stack_id"
	FieldReleaseID = "release_id"
	FieldResource  = "resource"
	FieldComponent = "component"
)

Field name constants for structured logging. Callers attach these via WithField/WithFields instead of interpolating IDs into message strings.

Variables

This section is empty.

Functions

func AddLoggerToContext

func AddLoggerToContext(ctx context.Context, logger Logger) context.Context

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) (string, bool)

func WithClusterID

func WithClusterID(ctx context.Context, id string) context.Context

func WithOrgID

func WithOrgID(ctx context.Context, id string) context.Context

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID stamps a request/correlation ID onto the context so every context-aware log call made downstream carries it as a structured field.

func WithUserID

func WithUserID(ctx context.Context, id string) context.Context

Types

type Logger

type Logger interface {
	SetLevel(level logrus.Level) Logger

	GetLevel() logrus.Level

	// WithField returns a child logger that attaches the given key/value to
	// every subsequent log entry. The parent is left unchanged.
	WithField(key string, value interface{}) Logger

	// WithFields returns a child logger that attaches all the given fields to
	// every subsequent log entry. The parent is left unchanged.
	WithFields(fields map[string]interface{}) Logger

	DebugEnabled() bool

	// InfoEnabled returns true if the information level is enabled.
	InfoEnabled() bool

	// WarnEnabled returns true if the warning level is enabled.
	WarnEnabled() bool

	// ErrorEnabled returns true if the error level is enabled.
	ErrorEnabled() bool

	// Debug sends to the log a debug message formatted using the fmt.Sprintf function and the
	// given format and arguments.
	Debug(ctx context.Context, format string, args ...interface{})

	// Info sends to the log an information message formatted using the fmt.Sprintf function and
	// the given format and arguments.
	Infof(format string, args ...interface{})

	Info(ctx context.Context, format string, args ...interface{})

	// Warn sends to the log a warning message formatted using the fmt.Sprintf function and the
	// given format and arguments.
	Warn(ctx context.Context, format string, args ...interface{})

	// Error sends to the log an error message formatted using the fmt.Sprintf function and
	// the given format and arguments.
	Error(ctx context.Context, format string, args ...interface{})

	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Warnf(format string, args ...interface{})

	// Fatal sends to the log an error message formatted using the fmt.Sprintf function and
	// the given format and arguments; and then executes an os.Exit(1)
	// Fatal level is always enabled
	Fatal(ctx context.Context, format string, args ...interface{})
}

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context) Logger

func NewLogger

func NewLogger() Logger

NewLogger creates a new logger instance with standard configuration

func NewLoggerWithDebug

func NewLoggerWithDebug(ctx context.Context) Logger

func NewLoggerWithPrefix

func NewLoggerWithPrefix(ctx context.Context, prefix string) Logger

Jump to

Keyboard shortcuts

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