Documentation
¶
Index ¶
- Variables
- func ClearContext()
- func CloseFileWriter() error
- func Debug() *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func GetLogFilePath() string
- func Info() *zerolog.Event
- func Init()
- func InitWithFile(debug bool, logsDir string, cfg *LoggingConfig) error
- func SetContext(project, agent string)
- func Warn() *zerolog.Event
- func WithField(key string, value interface{}) zerolog.Logger
- type LoggingConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Log is the global logger instance (file-only; nop before InitWithFile) Log zerolog.Logger )
Functions ¶
func CloseFileWriter ¶
func CloseFileWriter() error
CloseFileWriter closes the file writer if it exists. Call this on program shutdown for clean log file closure.
func Fatal ¶
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 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.
Types ¶
type LoggingConfig ¶
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.