utils

package
v0.0.0-...-8fc0724 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetZapLog

func GetZapLog(c *LogConfig) (*zap.Logger, error)

func ParseAddress

func ParseAddress(addr string) (host string, port int, err error)

ParseAddress 解析地址字符串,返回主机和端口

func TimeFormat

func TimeFormat(t time.Time) string

Types

type LogConfig

type LogConfig struct {
	Level      string `json:"level"`
	Filename   string `json:"filename"`
	MaxSize    int    `json:"max_size"`
	MaxAge     int    `json:"max_age"`
	MaxBackups int    `json:"max_backups"`
	Compress   bool   `json:"compress"`
	LocalTime  bool   `json:"local_time"`
}

func NewLogConfig

func NewLogConfig(option ...Option) *LogConfig

func (*LogConfig) WithOptions

func (log *LogConfig) WithOptions(opts ...Option) *LogConfig

type Option

type Option interface {
	// contains filtered or unexported methods
}

An Option configures a Logger.

func Compress

func Compress(compress bool) Option

func FileName

func FileName(fileName string) Option

FileName wraps or replaces the Logger's underlying zapcore.Core.

func LogLevel

func LogLevel(level string) Option

func MaxAge

func MaxAge(maxAge int) Option

func MaxBackups

func MaxBackups(maxBackups int) Option

func MaxSize

func MaxSize(maxSize int) Option

Jump to

Keyboard shortcuts

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