logger

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultLogStdout     = "console"
	DefaultLogLevel      = "info"
	DefaultLogDirectory  = "./log"
	DefaultLogMaxSize    = 100
	DefaultLogMaxBackups = 3
	DefaultLogMaxAge     = 7
)

Variables

View Source
var LogDir string
View Source
var LogHandler http.Handler

Functions

func SetupLogger

func SetupLogger()

SetupLogger initializes the zap-backed global logger. Called once at startup. Uses LogDir and config.DebugEnabled to configure output and level.

Types

type ILogger

type ILogger interface {
	Debugf(format string, args ...interface{})
	Debugw(msg string, keysAndValues ...interface{})
	Infof(format string, args ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnf(format string, args ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorf(format string, args ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	DPanicf(format string, args ...interface{})
	DPanicw(msg string, keysAndValues ...interface{})
	Panicf(format string, args ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})
	Enable(level string) bool
}
var Log ILogger

func NewLogger

func NewLogger(config *LogCfg) (ILogger, error)

type LogCfg

type LogCfg struct {
	Stdout     string `json:"stdout"`
	Level      string `json:"level"`
	Directory  string `json:"directory"`
	MaxSize    int    `json:"max_size"`
	MaxBackups int    `json:"max_backups"`
	MaxAge     int    `json:"max_age"`
}

type LogWriter

type LogWriter struct{}

LogWriter is an io.Writer that forwards each write to Log.Infof. Use it to bridge stdlib log consumers (e.g. GORM) into the zap backend.

func (*LogWriter) Write

func (w *LogWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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