logger

package
v0.0.0-...-66cf1cd Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package logger @program: gin-template @author: [lliuhuan](https://github.com/lliuhuan) @create: 2024-07-02 22:12

Index

Constants

View Source
const (
	// DefaultLevel 默认日志级别
	DefaultLevel = zapcore.InfoLevel

	// DefaultTimeLayout 默认时间格式
	DefaultTimeLayout = time.RFC3339
)

Variables

This section is empty.

Functions

func NewJSONLogger

func NewJSONLogger(opts ...Option) (*zap.Logger, error)

NewJSONLogger 返回一个 json-encoder zap 记录器,

func WrapMeta

func WrapMeta(err error, metas ...Meta) (fields []zap.Field)

WrapMeta 将元数据包装到 zap 字段

Types

type Meta

type Meta interface {
	Key() string
	Value() interface{}
	// contains filtered or unexported methods
}

Meta key-value

func NewMeta

func NewMeta(key string, value interface{}) Meta

NewMeta create meat

type Option

type Option func(*option)

Option 自定义设置配置

func WithDebugLevel

func WithDebugLevel() Option

WithDebugLevel 只有大于 debug 才会输出

func WithDisableConsole

func WithDisableConsole() Option

WithDisableConsole 禁止将日志写入 os.Stdout 或 os.Stderr

func WithErrorLevel

func WithErrorLevel() Option

WithErrorLevel 只有大于 error 才会输出

func WithField

func WithField(key, value string) Option

WithField 添加一些字段到日志中

func WithFileP

func WithFileP(file string) Option

WithFileP 将日志写入某个文件

func WithFileRotationP

func WithFileRotationP(file string) Option

WithFileRotationP 将日志写入某个文件, 并且进行日志切割

func WithInfoLevel

func WithInfoLevel() Option

WithInfoLevel 只有大于 info 才会输出

func WithTimeLayout

func WithTimeLayout(timeLayout string) Option

WithTimeLayout 自定义时间格式

func WithWarnLevel

func WithWarnLevel() Option

WithWarnLevel 只有大于 warn 才会输出

Jump to

Keyboard shortcuts

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