emlogrus

package module
v0.0.0-...-8704346 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

easy mix logrus


简单混入logrus,日志工具库

示例

package test

import (
	log "gitee.com/zrqcjz/emix-logrus"
	"testing"
)
func TestYamlLog(t *testing.T) {
	log.AfterInit("yml文件路径").Setup()
	//log.GlobalLevel = log.InfoLog
	log.Info("信息")
	log.DebugWith(log.Fields{"a": 12}, "debug")
	log.Warnf("警告 %e", 112112.3434)
	log.Error("错误")
}

Documentation

Index

Constants

View Source
const (
	ConsoleOut LogOutType = "console"
	FileOut               = "file"
	DebugLog   LogLevel   = "debug"
	InfoLog               = "info"
	WarnLog               = "warn"
	ErrorLog              = "error"
	TextLog    LogFormat  = "text"
	JsonLog               = "json"
)

Variables

View Source
var GlobalLevel = DebugLog

Functions

func Debug

func Debug(args ...interface{})

func DebugWith

func DebugWith(fields map[string]interface{}, args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func DebugfWith

func DebugfWith(fields map[string]interface{}, format string, args ...interface{})

func Error

func Error(args ...interface{})

func ErrorWith

func ErrorWith(fields map[string]interface{}, args ...interface{})

func Errorf

func Errorf(format string, args ...interface{})

func ErrorfWith

func ErrorfWith(fields map[string]interface{}, format string, args ...interface{})

func Info

func Info(args ...interface{})

func InfoWith

func InfoWith(fields map[string]interface{}, args ...interface{})

func Infof

func Infof(format string, args ...interface{})

func InfofWith

func InfofWith(fields map[string]interface{}, format string, args ...interface{})

func Warn

func Warn(args ...interface{})

func WarnWith

func WarnWith(fields map[string]interface{}, args ...interface{})

func Warnf

func Warnf(format string, args ...interface{})

func WarnfWith

func WarnfWith(fields map[string]interface{}, format string, args ...interface{})

Types

type EmixConfig

type EmixConfig struct {
	Log []LogConfig `yaml:"log,flow"`
}

type Fields

type Fields map[string]interface{}

type LogConfig

type LogConfig struct {
	Level       LogLevel   `yaml:"level"`
	Format      LogFormat  `yaml:"format"`
	OutType     LogOutType `yaml:"outType"`
	OutDir      string     `yaml:"outDir"`
	MaxAge      int        `yaml:"maxAge"`
	MaxCount    uint       `yaml:"maxCount"`
	SingleLevel bool       `yaml:"singleLevel"`
	Disabled    bool       `yaml:"disabled"`
}

func (LogConfig) Option

func (r LogConfig) Option() Option

type LogEntry

type LogEntry struct {
	// contains filtered or unexported fields
}

func NewLogEntry

func NewLogEntry(lcs ...LogConfig) *LogEntry

func NewLogEntryFromOption

func NewLogEntryFromOption(ops ...Option) *LogEntry

func (*LogEntry) Debug

func (l *LogEntry) Debug(args ...interface{})

func (*LogEntry) DebugWith

func (l *LogEntry) DebugWith(fields map[string]interface{}, args ...interface{})

func (*LogEntry) Debugf

func (l *LogEntry) Debugf(format string, args ...interface{})

func (*LogEntry) DebugfWith

func (l *LogEntry) DebugfWith(fields map[string]interface{}, format string, args ...interface{})

func (*LogEntry) Error

func (l *LogEntry) Error(args ...interface{})

func (*LogEntry) ErrorWith

func (l *LogEntry) ErrorWith(fields map[string]interface{}, args ...interface{})

func (*LogEntry) Errorf

func (l *LogEntry) Errorf(format string, args ...interface{})

func (*LogEntry) ErrorfWith

func (l *LogEntry) ErrorfWith(fields map[string]interface{}, format string, args ...interface{})

func (*LogEntry) Info

func (l *LogEntry) Info(args ...interface{})

func (*LogEntry) InfoWith

func (l *LogEntry) InfoWith(fields map[string]interface{}, args ...interface{})

func (*LogEntry) Infof

func (l *LogEntry) Infof(format string, args ...interface{})

func (*LogEntry) InfofWith

func (l *LogEntry) InfofWith(fields map[string]interface{}, format string, args ...interface{})

func (*LogEntry) Warn

func (l *LogEntry) Warn(args ...interface{})

func (*LogEntry) WarnWith

func (l *LogEntry) WarnWith(fields map[string]interface{}, args ...interface{})

func (*LogEntry) Warnf

func (l *LogEntry) Warnf(format string, args ...interface{})

func (*LogEntry) WarnfWith

func (l *LogEntry) WarnfWith(fields map[string]interface{}, format string, args ...interface{})

type LogFormat

type LogFormat string

func (LogFormat) Logrus

func (r LogFormat) Logrus() logrus.Formatter

type LogLevel

type LogLevel string

func (LogLevel) Logrus

func (r LogLevel) Logrus() logrus.Level

type LogOutType

type LogOutType string

type Operation

type Operation struct {
	Lcs []LogConfig
}

func AfterInit

func AfterInit(yamlFile string, cs ...LogConfig) (oper Operation)

func (Operation) Setup

func (r Operation) Setup()

type Option

type Option struct {
	Level       logrus.Level
	Format      logrus.Formatter
	OutType     LogOutType
	OutDir      string
	MaxAge      time.Duration
	MaxCount    uint
	SingleLevel bool
	Disabled    bool
}

type OptionLogger

type OptionLogger struct {
	*logrus.Logger
	Op Option
}

func (*OptionLogger) Log

func (r *OptionLogger) Log(level logrus.Level, args ...interface{})

func (*OptionLogger) Logf

func (r *OptionLogger) Logf(level logrus.Level, format string, args ...interface{})

func (*OptionLogger) Logln

func (r *OptionLogger) Logln(level logrus.Level, args ...interface{})

type RootConfig

type RootConfig struct {
	Emix EmixConfig `yaml:"emix"`
}

Jump to

Keyboard shortcuts

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