log

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package log

Package log

Package log

Package log

Package log

Package log

Index

Constants

View Source
const EncodingConsole = "console"
View Source
const EncodingJSON = "json"

Variables

View Source
var DefaultOption = Option{
	Development:  false,
	Level:        InfoLevel,
	StackTrace:   false,
	Encoding:     EncodingJSON,
	Output:       DefaultOutput,
	EncodeConfig: zapEncodeConfig,
}

DefaultOption 默认配置

View Source
var DefaultOutput = []string{"stderr"}

DefaultOutput 默认会记录到stderr fatal错误不会被记录

View Source
var DevOption = Option{
	Development:  true,
	Level:        DebugLevel,
	StackTrace:   true,
	Encoding:     EncodingJSON,
	Output:       DefaultOutput,
	EncodeConfig: zapEncodeConfig,
}

Functions

func ConvertConfig

func ConvertConfig(op Option) zap.Config

ConvertConfig 从fushin option转为zap config

func DefaultEncodeConfig

func DefaultEncodeConfig() zapcore.EncoderConfig

func ModuleName

func ModuleName() string

func NewZap

func NewZap(c zap.Config, op ...zap.Option) (*zap.Logger, error)

NewZap 不使用sugar而是使用原生的zap logger

Types

type Level

type Level int8
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel Level = iota - 1
	// InfoLevel is the default logging priority.
	InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

type Logger

type Logger struct {
	Name   string
	Option Option
	Sync   bool
	// contains filtered or unexported fields
}

func Default

func Default(name string) *Logger

func Dev

func Dev(name string) *Logger

func New

func New(name string, op Option) *Logger

New 新建日志

func Raw

func Raw(name string, c zap.Config, op ...zap.Option) Logger

Raw 使用zap原生配置创建

func (Logger) Error

func (l Logger) Error(v ...interface{})

func (Logger) ErrorF

func (l Logger) ErrorF(fmtStr string, v ...interface{})

func (Logger) Info

func (l Logger) Info(v ...interface{})

func (Logger) InfoF

func (l Logger) InfoF(fmtStr string, v ...interface{})

func (*Logger) Init

func (l *Logger) Init() error

Init 从Logger内置的参数新建日志构建logger

func (Logger) Warn

func (l Logger) Warn(v ...interface{})

func (Logger) WarnF

func (l Logger) WarnF(fmtStr string, v ...interface{})

type LoggerInterface added in v1.0.5

type LoggerInterface interface {
	Info(v ...interface{})
	Warn(v ...interface{})
	Error(v ...interface{})
	InfoF(fmt string, v ...interface{})
	WarnF(fmt string, v ...interface{})
	ErrorF(fmt string, v ...interface{})
}

type LoggerPanic added in v1.0.5

type LoggerPanic interface {
	Panic(v ...interface{})
	PanicF(fmt string, v ...interface{})
}

type Option

type Option struct {
	Development  bool
	Level        Level
	EnableCaller bool
	StackTrace   bool
	Encoding     string
	Output       []string
	EncodeConfig zapcore.EncoderConfig // 原生的zap配置
}

Option 日志的配置项

Directories

Path Synopsis
Package private
Package private

Jump to

Keyboard shortcuts

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