logger

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Log is the global logger instance (file-only; nop before InitWithFile)
	Log zerolog.Logger
)

Functions

func ClearContext

func ClearContext()

ClearContext clears the project/agent context.

func CloseFileWriter

func CloseFileWriter() error

CloseFileWriter closes the file writer if it exists. Call this on program shutdown for clean log file closure.

func Debug

func Debug() *zerolog.Event

Debug logs a debug message (developer diagnostics, file-only)

func Error

func Error() *zerolog.Event

Error logs an error message (file-only)

func Fatal

func Fatal() *zerolog.Event

Fatal logs a fatal message and exits (file-only). NEVER use in Cobra hooks — return errors instead.

func GetLogFilePath

func GetLogFilePath() string

GetLogFilePath returns the path to the current log file, or empty string if file logging is disabled.

func Info

func Info() *zerolog.Event

Info logs an info message (file-only)

func Init

func Init()

Init initializes the global logger as a nop logger. This is the pre-file-logging placeholder — all log output is discarded until InitWithFile is called with a valid logs directory.

func InitWithFile

func InitWithFile(debug bool, logsDir string, cfg *LoggingConfig) error

InitWithFile initializes the logger with file-only output. Zerolog never writes to the console — user-visible output uses fmt.Fprintf to IOStreams (see code style guide). If logsDir is empty or cfg indicates file logging is disabled, the logger remains a nop.

func SetContext

func SetContext(project, agent string)

SetContext sets project and agent context for all subsequent log entries. Pass empty strings to clear. Thread-safe.

func Warn

func Warn() *zerolog.Event

Warn logs a warning message (file-only)

func WithField

func WithField(key string, value interface{}) zerolog.Logger

WithField returns a logger with an additional field

Types

type LoggingConfig

type LoggingConfig struct {
	FileEnabled *bool
	MaxSizeMB   int
	MaxAgeDays  int
	MaxBackups  int
}

LoggingConfig holds configuration for file-based logging. This matches internal/config.LoggingConfig but is duplicated here to avoid circular imports.

func (*LoggingConfig) GetMaxAgeDays

func (c *LoggingConfig) GetMaxAgeDays() int

GetMaxAgeDays returns the max age in days, defaulting to 7 if not set.

func (*LoggingConfig) GetMaxBackups

func (c *LoggingConfig) GetMaxBackups() int

GetMaxBackups returns the max backups, defaulting to 3 if not set.

func (*LoggingConfig) GetMaxSizeMB

func (c *LoggingConfig) GetMaxSizeMB() int

GetMaxSizeMB returns the max size in MB, defaulting to 50 if not set.

func (*LoggingConfig) IsFileEnabled

func (c *LoggingConfig) IsFileEnabled() bool

IsFileEnabled returns whether file logging is enabled. Defaults to true if not explicitly set.

Jump to

Keyboard shortcuts

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