logger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package logger provides configurable logging capabilities

internal/logger/logger.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugTagf

func DebugTagf(tag, format string, args ...interface{})

DebugTagf logs a debug message with a tag using Printf-style formatting.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs a debug message using Printf-style formatting.

func EnableFilterDebug

func EnableFilterDebug(enable bool)

EnableFilterDebug turns on debug output for filtering decisions

func ErrorTagf

func ErrorTagf(tag, format string, args ...interface{})

ErrorTagf logs an error message with a tag using Printf-style formatting.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs an error message using Printf-style formatting.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logs an error message then exits.

func Get

func Get() *slog.Logger

Get retrieves the configured logger instance.

func InfoTagf

func InfoTagf(tag, format string, args ...interface{})

InfoTagf logs an info message with a tag using Printf-style formatting.

func Infof

func Infof(format string, args ...interface{})

Infof logs an info message using Printf-style formatting.

func Init

func Init(cfg Config)

Init initializes the logger package with the given configuration.

func WarnTagf

func WarnTagf(tag, format string, args ...interface{})

WarnTagf logs a warning message with a tag using Printf-style formatting.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a warning message using Printf-style formatting.

Types

type Config

type Config struct {
	// LogLevel specifies the minimum level to log (e.g., "debug", "info", "warn", "error").
	LogLevel string

	// LogFilePath is the path to the output log file. Use empty or "-" for stderr.
	LogFilePath string

	// EnabledTags only logs messages with these tags (if non-empty).
	EnabledTags []string
	// DisabledTags prevents logging messages with these tags. Overrides EnabledTags.
	DisabledTags []string

	// EnabledPackages only logs messages originating from these packages (if non-empty).
	// Package name is the immediate directory name (e.g., "core", "theme", "app").
	EnabledPackages []string
	// DisabledPackages prevents logging from these packages. Overrides EnabledPackages.
	DisabledPackages []string

	// EnabledFiles only logs messages originating from these filenames (if non-empty).
	// Filename is the base name (e.g., "editor.go", "manager.go").
	EnabledFiles []string
	// DisabledFiles prevents logging from these filenames. Overrides EnabledFiles.
	DisabledFiles []string
	// contains filtered or unexported fields
}

Config holds all settings for the logger.

func NewConfig

func NewConfig() Config

NewConfig creates a new Config with default values

Jump to

Keyboard shortcuts

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