logger

package
v0.0.0-...-d7d4aa8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string)

Debug *

  • @Description:
  • @param msg
Example
Debug("example")
Output:

func DebugCtx

func DebugCtx(ctx context.Context, msg string)

DebugCtx *

  • @Description:
  • @param ctx
  • @param msg
Example
DebugCtx(context.TODO(), "example")
Output:

func Error

func Error(msg string)

Error *

  • @Description:
  • @param msg

func ErrorCtx

func ErrorCtx(ctx context.Context, msg string)

ErrorCtx *

  • @Description:
  • @param ctx
  • @param msg

func Fatal

func Fatal(msg string)

Fatal *

  • @Description:
  • @param msg

func FatalCtx

func FatalCtx(ctx context.Context, msg string)

FatalCtx *

  • @Description:
  • @param ctx
  • @param msg

func Info

func Info(msg string)

Info *

  • @Description:
  • @param msg

func InfoCtx

func InfoCtx(ctx context.Context, msg string)

InfoCtx *

  • @Description:
  • @param ctx
  • @param msg

func New

func New(cfg *Config)
Example
New(nil)
Output:

func NewContext

func NewContext(ctx context.Context, fields ...zapcore.Field) context.Context

NewContext *

  • @Description:
  • @param ctx
  • @param fields
  • @return context.Context

func NewLogger

func NewLogger(exporters ...IExporter)

func OnlyConsole

func OnlyConsole()

func Warn

func Warn(msg string)

Warn *

  • @Description:
  • @param msg

func WarnCtx

func WarnCtx(ctx context.Context, msg string)

WarnCtx *

  • @Description:
  • @param ctx
  • @param msg

func WithContext

func WithContext(ctx context.Context) *zap.Logger

WithContext *

  • @Description:
  • @param ctx
  • @return *zap.Logger

Types

type Config

type Config struct {
	StdLevel      string `toml:"std_level" json:"std_level"`     // Std Log level.
	StdFormat     string `toml:"std_format" json:"std_format"`   // Std Log format. one of json, text, or console.
	Level         string `toml:"level" json:"level"`             // Log level.
	Format        string `toml:"format" json:"format"`           // Log format. one of json, text, or console.
	FileDirectory string `toml:"file_dir" json:"file_dir"`       // File directory
	FileName      string `toml:"file_name" json:"file_name"`     // Log filename, leave empty to disable file log.
	MaxSize       int    `toml:"max_size" json:"max_size"`       // Max size for a single file, in MB.
	MaxDays       int    `toml:"max_days" json:"max_days"`       // Max log keep days, default is never deleting.
	MaxBackups    int    `toml:"max_backups" json:"max_backups"` // Maximum number of old log files to retain.
	Compress      bool   `toml:"compress" json:"compress"`       // Compress
}

Config cfg logger

func (*Config) GetLevel

func (c *Config) GetLevel() *Level

GetLevel Get File Level

func (*Config) GetStdLevel

func (c *Config) GetStdLevel() *Level

GetStdLevel Get Std Level

type FileExporter

type FileExporter struct{}

func (*FileExporter) Encoder

func (e *FileExporter) Encoder() zapcore.Encoder

Encoder *

  • @Description:
  • @receiver e
  • @return zapcore.Encoder

func (*FileExporter) Level

func (e *FileExporter) Level() zapcore.Level

Level *

  • @Description:
  • @receiver e
  • @return zapcore.Level

func (*FileExporter) Writer

func (e *FileExporter) Writer() zapcore.WriteSyncer

Writer *

  • @Description:
  • @receiver e
  • @return zapcore.WriteSyncer

type IExporter

type IExporter interface {
	Encoder() zapcore.Encoder
	Writer() zapcore.WriteSyncer
	Level() zapcore.Level
}

func NewExporters

func NewExporters() []IExporter

type Level

type Level int8

Level is a logging priority. Higher levels are more important.

const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel // Critical exists only for config backward compatibility.
)

Logging levels.

func (Level) String

func (l Level) String() string

String returns the name of the logging level.

func (Level) Unabled

func (l Level) Unabled(level Level) bool

Unabled returns true if given level is enabled.

func (*Level) Unpack

func (l *Level) Unpack(str string) error

Unpack unmarshals a level string to a Level. This implements ucfg.StringUnpacker.

type StdExporter

type StdExporter struct{}

func (*StdExporter) Encoder

func (e *StdExporter) Encoder() zapcore.Encoder

Encoder *

  • @Description:
  • @receiver e
  • @return zapcore.Encoder

func (*StdExporter) Level

func (e *StdExporter) Level() zapcore.Level

Level *

  • @Description:
  • @receiver e
  • @return zapcore.Level

func (*StdExporter) Writer

func (e *StdExporter) Writer() zapcore.WriteSyncer

Writer *

  • @Description:
  • @receiver e
  • @return zapcore.WriteSyncer

Jump to

Keyboard shortcuts

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