logger

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Level 日志级别

Functions

func NewJSONLogger

func NewJSONLogger(debug bool, w io.Writer) *zap.Logger

NewJSONLogger 创建JSON日志

func SetCrashOutput

func SetCrashOutput(f *os.File) error

SetCrashOutput recover panic

func SetLevel

func SetLevel(l string)

SetLevel 设置日志级别 debug/warn/error

func SetupSlog

func SetupSlog(cfg Config) (*slog.Logger, func())

SetupSlog 初始化日志

Types

type Config

type Config struct {
	Dir          string
	ID           string
	Name         string
	Version      string
	Debug        bool
	MaxAge       time.Duration
	RotationTime time.Duration
	RotationSize int64  // 单位字节
	Level        string // debug/info/warn/error
}

Config ....

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig 创建默认配置

Jump to

Keyboard shortcuts

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