logger

package
v0.0.0-...-37b37ea Latest Latest
Warning

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

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

Documentation

Overview

Package logger provides structured logging with automatic secret redaction

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a debug message using the global logger

func Error

func Error(msg string)

Error logs an error message using the global logger

func Fatal

func Fatal(msg string)

Fatal logs a fatal message using the global logger and exits

func Info

func Info(msg string)

Info logs an info message using the global logger

func RedactSecret

func RedactSecret(secret string) string

RedactSecret redacts sensitive information from logs IMPORTANT: Never log raw secrets, keys, or shares

func SetGlobalLogger

func SetGlobalLogger(logger *Logger)

SetGlobalLogger sets the global logger instance

func Warn

func Warn(msg string)

Warn logs a warning message using the global logger

Types

type Config

type Config struct {
	// Level is the minimum log level (debug, info, warn, error)
	Level string

	// Output is where logs are written (default: os.Stdout)
	Output io.Writer

	// Pretty enables human-readable console output
	Pretty bool

	// TimeFormat for timestamps (default: RFC3339)
	TimeFormat string

	// CallerEnabled adds file and line number to logs
	CallerEnabled bool
}

Config holds logger configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns default logger configuration

type Context

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

Context provides fluent API for adding fields to logs

func (*Context) Bool

func (c *Context) Bool(key string, val bool) *Context

Bool adds a boolean field

func (*Context) Dur

func (c *Context) Dur(key string, val time.Duration) *Context

Dur adds a duration field

func (*Context) Err

func (c *Context) Err(err error) *Context

Err adds an error field (automatically redacts sensitive info)

func (*Context) Int

func (c *Context) Int(key string, val int) *Context

Int adds an int field

func (*Context) Logger

func (c *Context) Logger() *Logger

Logger returns the configured logger

func (*Context) Str

func (c *Context) Str(key, val string) *Context

Str adds a string field

type Event

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

Event represents a log event

func (*Event) Bool

func (e *Event) Bool(key string, val bool) *Event

Bool adds a boolean field to the event

func (*Event) Dur

func (e *Event) Dur(key string, val time.Duration) *Event

Dur adds a duration field to the event

func (*Event) Err

func (e *Event) Err(err error) *Event

Err adds an error field to the event

func (*Event) Int

func (e *Event) Int(key string, val int) *Event

Int adds an int field to the event

func (*Event) Msg

func (e *Event) Msg(msg string)

Msg completes the event with a message

func (*Event) Str

func (e *Event) Str(key, val string) *Event

Str adds a string field to the event

type Logger

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

Logger wraps zerolog.Logger with additional security features

func New

func New(cfg *Config) *Logger

New creates a new logger with the given configuration

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a debug message

func (*Logger) DebugEvent

func (l *Logger) DebugEvent() *Event

Debug returns a debug event

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs an error message

func (*Logger) ErrorEvent

func (l *Logger) ErrorEvent() *Event

ErrorEvent returns an error event

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

Fatal logs a fatal message and exits

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs an info message

func (*Logger) InfoEvent

func (l *Logger) InfoEvent() *Event

InfoEvent returns an info event

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a warning message

func (*Logger) WarnEvent

func (l *Logger) WarnEvent() *Event

WarnEvent returns a warn event

func (*Logger) With

func (l *Logger) With() *Context

With creates a child logger with additional context

Jump to

Keyboard shortcuts

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