log

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugCtx

func DebugCtx(ctx context.Context, msg string, fields ...zap.Field)

DebugCtx logs a message at level Debug with log id.

func ErrorCtx

func ErrorCtx(ctx context.Context, msg string, fields ...zap.Field)

ErrorCtx logs a message at level Error with log id.

func GenerateLogID

func GenerateLogID() string

func InfoCtx

func InfoCtx(ctx context.Context, msg string, fields ...zap.Field)

InfoCtx logs a message at level Info with log id.

func New

func New(cfg *Config)

func Sync

func Sync() error

Sync flushes any buffered log entries.

func WarnCtx

func WarnCtx(ctx context.Context, msg string, fields ...zap.Field)

WarnCtx logs a message at level Warn with log id.

Types

type Config

type Config struct {
	File        FileConfig  `json:"enable_file"`
	Level       LoggerLevel `json:"level"`
	Caller      bool        `json:"caller"`
	DefaultTags map[string]interface{}
}

type FileConfig

type FileConfig struct {
	Enable       bool   `json:"enable"`
	FileLocation string `json:"file_location"`
	MaxSize      int    `json:"max_size"`
	MaxBackups   int    `json:"max_backups"`
	MaxAge       int    `json:"max_age"`
	Compress     bool   `json:"compress"`
}

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}
var Log *Logger

type LoggerLevel

type LoggerLevel string
const (
	// LoggerLevelDebug is the debug level
	LoggerLevelDebug LoggerLevel = "debug"
	// LoggerLevelInfo is the info level
	LoggerLevelInfo LoggerLevel = "info"
	// LoggerLevelWarn is the warn level
	LoggerLevelWarn LoggerLevel = "warn"
	// LoggerLevelError is the error level
	LoggerLevelError LoggerLevel = "error"
)

Jump to

Keyboard shortcuts

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