log

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const ConfigKey = "web.log"

ConfigKey is the configuration key under which logger settings are stored.

Variables

View Source
var TimestampFormat = "2006-01-02 15:04:05"

TimestampFormat is the time format used in log output.

Functions

func Debug added in v0.1.1

func Debug(msg string, fields ...zap.Field)

Debug logs a debug-level message.

func Error added in v0.1.1

func Error(msg string, fields ...zap.Field)

Error logs an error message.

func Errors added in v0.1.1

func Errors(msg string, errs ...error)

Errors logs an error message with one or more error values.

func Fatal added in v0.1.1

func Fatal(msg string, fields ...zap.Field)

Fatal logs a fatal message and calls os.Exit(1).

func Info added in v0.1.1

func Info(msg string, fields ...zap.Field)

Info logs an informational message.

func InitLogger

func InitLogger(logConfig *Config)

InitLogger initializes or reconfigures the global logger with the given config.

func Panic added in v0.1.1

func Panic(msg string, fields ...zap.Field)

Panic logs a panic message and then panics. Error fields are also printed via log.Printf for stack trace visibility.

func PanicErrors added in v0.1.1

func PanicErrors(msg string, errs ...error)

PanicErrors logs a panic message with error values and prints them via log.Printf. Unlike zap.Panic, this only logs the message without actually panicking.

func PrintPanic added in v0.1.3

func PrintPanic(errs ...error)

PrintPanic prints error stack traces via log.Printf without panicking.

func Sync added in v0.1.1

func Sync() error

Sync flushes any buffered log entries.

func Warn added in v0.1.1

func Warn(msg string, fields ...zap.Field)

Warn logs a warning message.

Types

type Config added in v0.1.1

type Config struct {
	Level      string // Log level: debug, info, warn, error
	Path       string // Log file path
	Write      bool   // Whether to enable file-based logging
	MaxSize    int    // Max size per log file (MB), default 500
	MaxBackups int    // Max number of old log files retained, default 3
	MaxAge     int    // Max days to retain old log files, default 30
	Compress   bool   // Whether to compress old log files, default true
	LocalTime  bool   // Whether to use local time, default false (UTC)
}

Config holds the logger configuration settings.

Jump to

Keyboard shortcuts

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