logging

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package logging provides structured logging with file rotation for nightshift. Supports JSON and text formats with date-based log file naming.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug logs a debug message to the global logger.

func Error

func Error(msg string)

Error(msg string) logs an error message to the global logger.

func Info

func Info(msg string)

Info logs an info message to the global logger.

func Init

func Init(cfg Config) error

Init initializes the global logger with the given configuration.

func Warn

func Warn(msg string)

Warn logs a warning message to the global logger.

Types

type Config

type Config struct {
	Level         string // debug, info, warn, error
	Path          string // Log directory path
	Format        string // json, text
	RetentionDays int    // Days to keep logs (default 7)
}

Config holds logging configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default logging configuration.

type Logger

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

Logger wraps zerolog with nightshift-specific functionality.

func Component

func Component(name string) *Logger

Component returns a logger with the specified component.

func Get

func Get() *Logger

Get returns the global logger.

func New

func New(cfg Config) (*Logger, error)

New creates a new Logger instance.

func (*Logger) Close

func (l *Logger) Close() error

Close closes the log file.

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a debug message.

func (*Logger) DebugCtx

func (l *Logger) DebugCtx(msg string, fields map[string]any)

DebugCtx logs a debug message with context fields.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

Debugf logs a formatted debug message.

func (*Logger) Err

func (l *Logger) Err(err error) *zerolog.Event

Err logs an error with the error field.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs an error message.

func (*Logger) ErrorCtx

func (l *Logger) ErrorCtx(msg string, fields map[string]any)

ErrorCtx logs an error message with context fields.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

Errorf logs a formatted error message.

func (*Logger) Event

func (l *Logger) Event(level string) *zerolog.Event

Event returns a new log event at the specified level.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs an info message.

func (*Logger) InfoCtx

func (l *Logger) InfoCtx(msg string, fields map[string]any)

InfoCtx logs an info message with context fields.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

Infof logs a formatted info message.

func (*Logger) LogFiles

func (l *Logger) LogFiles() ([]string, error)

LogFiles returns a list of log files sorted by date (newest first).

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a warning message.

func (*Logger) WarnCtx

func (l *Logger) WarnCtx(msg string, fields map[string]any)

WarnCtx logs a warning message with context fields.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

Warnf logs a formatted warning message.

func (*Logger) With

func (l *Logger) With() zerolog.Context

With returns a new Logger with additional context fields.

func (*Logger) WithComponent

func (l *Logger) WithComponent(component string) *Logger

WithComponent returns a new Logger with the component field set.

Jump to

Keyboard shortcuts

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