logs

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelTrace = "trace"
	LogLevelDebug = "debug"
	LogLevelInfo  = "info"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
)

Log level constants

Variables

This section is empty.

Functions

func CleanupTestWriter

func CleanupTestWriter(file *os.File) error

CleanupTestWriter removes temporary test files

func CreateCLIUpstreamServerLogger

func CreateCLIUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, error)

CreateCLIUpstreamServerLogger creates a logger for CLI debugging that outputs to console

func CreateHTTPLogger

func CreateHTTPLogger(config *config.LogConfig) (*zap.Logger, error)

CreateHTTPLogger creates a logger specifically for HTTP API requests

func CreateTestWriter

func CreateTestWriter() (io.Writer, *os.File, error)

CreateTestWriter creates a writer for testing that captures both file and memory output

func CreateUpstreamServerLogger

func CreateUpstreamServerLogger(config *config.LogConfig, serverName string) (*zap.Logger, error)

CreateUpstreamServerLogger creates a logger for a specific upstream server

func DefaultLogConfig

func DefaultLogConfig() *config.LogConfig

DefaultLogConfig returns default logging configuration

func EnsureLogDir

func EnsureLogDir(logDir string) error

EnsureLogDir creates the log directory if it doesn't exist

func GetLogDir

func GetLogDir() (string, error)

GetLogDir returns the standard log directory for the current OS

func GetLogFilePath

func GetLogFilePath(filename string) (string, error)

GetLogFilePath returns the full path for a log file in the standard log directory

func GetLogFilePathWithDir

func GetLogFilePathWithDir(logDir, filename string) (string, error)

GetLogFilePathWithDir returns the full path for a log file in a custom log directory

func ReadUpstreamServerLogTail

func ReadUpstreamServerLogTail(config *config.LogConfig, serverName string, lines int) ([]string, error)

ReadUpstreamServerLogTail reads the last N lines from an upstream server log file

func SetupCommandLogger

func SetupCommandLogger(serverCommand bool, logLevel string, logToFile bool, logDir string) (*zap.Logger, error)

SetupCommandLogger creates a logger for console commands with appropriate default levels serverCommand: if true, uses INFO level by default; if false, uses WARN level by default

func SetupLogger

func SetupLogger(config *config.LogConfig) (*zap.Logger, error)

SetupLogger creates a logger with file and console outputs based on configuration

Types

type LogDirInfo

type LogDirInfo struct {
	Path        string `json:"path"`
	OS          string `json:"os"`
	Description string `json:"description"`
	Standard    string `json:"standard"`
}

LogDirInfo returns information about the log directory for different OS

func GetLogDirInfo

func GetLogDirInfo() (*LogDirInfo, error)

GetLogDirInfo returns detailed information about the log directory

type LoggerInfo

type LoggerInfo struct {
	LogDir        string    `json:"log_dir"`
	LogFile       string    `json:"log_file"`
	Level         string    `json:"level"`
	EnableFile    bool      `json:"enable_file"`
	EnableConsole bool      `json:"enable_console"`
	MaxSize       int       `json:"max_size"`
	MaxBackups    int       `json:"max_backups"`
	MaxAge        int       `json:"max_age"`
	Compress      bool      `json:"compress"`
	JSONFormat    bool      `json:"json_format"`
	CreatedAt     time.Time `json:"created_at"`
}

LoggerInfo represents information about the logger setup

func GetLoggerInfo

func GetLoggerInfo(config *config.LogConfig) (*LoggerInfo, error)

GetLoggerInfo returns information about the current logger configuration

type SecretSanitizer

type SecretSanitizer struct {
	zapcore.Core
	// contains filtered or unexported fields
}

SecretSanitizer wraps a zapcore.Core to sanitize sensitive values from logs

func NewSecretSanitizer

func NewSecretSanitizer(core zapcore.Core) *SecretSanitizer

NewSecretSanitizer creates a new sanitizing core that wraps the provided core

func (*SecretSanitizer) Check

func (s *SecretSanitizer) Check(entry zapcore.Entry, checkedEntry *zapcore.CheckedEntry) *zapcore.CheckedEntry

Check delegates to the wrapped core

func (*SecretSanitizer) RegisterResolvedSecret

func (s *SecretSanitizer) RegisterResolvedSecret(value string)

RegisterResolvedSecret registers a secret value that was resolved from keyring/env so it can be masked in logs

func (*SecretSanitizer) UnregisterResolvedSecret

func (s *SecretSanitizer) UnregisterResolvedSecret(value string)

UnregisterResolvedSecret removes a secret from the mask cache

func (*SecretSanitizer) With

func (s *SecretSanitizer) With(fields []zapcore.Field) zapcore.Core

With creates a sanitizing child core

func (*SecretSanitizer) Write

func (s *SecretSanitizer) Write(entry zapcore.Entry, fields []zapcore.Field) error

Write sanitizes the entry before writing

Jump to

Keyboard shortcuts

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