tylog

package
v0.0.0-...-cc3673b Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FormatEnumJSON    FormatEnum = "json"
	FormatEnumConsole FormatEnum = "console"

	DefaultRotatePeriodSecond int64 = 60 * 60 * 24 // 一天
)

Variables

Functions

func Any

func Any(key string, value interface{}) zap.Field

func ByteString

func ByteString(key string, val []byte) zap.Field

ByteString 会把[]byte转成string 注意 Any() 会把[]byte转成 binary

func Debug

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

Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Error

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

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func ErrorField

func ErrorField(err error) zap.Field

func Fatal

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

Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.

func Info

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

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func InfoField

func InfoField(v interface{}) zap.Field

func NewLog

func NewLog(config *LogConfig) *zap.Logger

func RotatePeriod

func RotatePeriod(l *lumberjack.Logger, periodSecond int64)

日志滚动周期

func SetGlobalLog

func SetGlobalLog(appName string, prod bool, opts ...OptionFunc)

func String

func String(key string, value string) zap.Field

func Warn

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

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

Types

type FormatEnum

type FormatEnum string

type FormatTime

type FormatTime = zapcore.TimeEncoder

type LevelEnum

type LevelEnum = zap.AtomicLevel

type LogConfig

type LogConfig struct {

	// hook
	Hooks []LogHook
	// contains filtered or unexported fields
}

func DefaultLogConfig

func DefaultLogConfig() *LogConfig

func ProdLogConfig

func ProdLogConfig(appName string) *LogConfig

type LogHook

type LogHook interface {
	DoHook(zapcore.Entry) error
}

type OptionFunc

type OptionFunc func(*LogConfig)

func WithAppNameOption

func WithAppNameOption(v string) OptionFunc

func WithDirOption

func WithDirOption(v string) OptionFunc

func WithFormatOption

func WithFormatOption(v FormatEnum) OptionFunc

func WithHooksOption

func WithHooksOption(hooks ...LogHook) OptionFunc

func WithLevelOption

func WithLevelOption(v LevelEnum) OptionFunc

func WithLocalTimeOption

func WithLocalTimeOption(v bool) OptionFunc

func WithMaxBackupsOption

func WithMaxBackupsOption(v int) OptionFunc

func WithMaxSizeOption

func WithMaxSizeOption(v int) OptionFunc

func WithMultiWriteOption

func WithMultiWriteOption(v bool) OptionFunc

func WithRotatePeriodSecondOption

func WithRotatePeriodSecondOption(v int64) OptionFunc

Jump to

Keyboard shortcuts

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