log

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

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

Go to latest
Published: Sep 17, 2018 License: MIT Imports: 5 Imported by: 12

README

log

a base log library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, data ...interface{})

func Error

func Error(msg string, data ...interface{})

func Fatal

func Fatal(msg string, data ...interface{})

Description: log message with fatal level, then fatal(), you should avoid use this.

  • Author: architect.bian
  • Date: 2018/09/17 13:40

func Info

func Info(msg string, data ...interface{})

func Panic

func Panic(msg string, data ...interface{})

Description: log message with panic level, then panic(), you should avoid use this.

  • Author: architect.bian
  • Date: 2018/09/17 13:40

func SetLevel

func SetLevel(lvl Level)

func UseLog

func UseLog(lg Logger)

func Warn

func Warn(msg string, data ...interface{})

Types

type Config

type Config struct {
	Use              string `json:"use" yaml:"use"`
	Level            Level
	LevelName        string   `json:"level" yaml:"level"`
	OutputPaths      []string `json:"outputPaths" yaml:"outputPaths"`
	ErrorOutputPaths []string `json:"errorOutputPaths" yaml:"errorOutputPaths"`
}

type Level

type Level int8
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in production.
	DebugLevel Level = iota
	// 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
	// DevDebugLevel logs are same as DebugLevel, but panic/fatal will print error like nomal
	DevDebugLevel
	// PanicLevel logs a message, then panics.
	PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

func LevelParse

func LevelParse(lvl string) Level

type Logger

type Logger interface {
	Initialize(conf *Config)
	SetLevel(lvl int8)
	Debug(msg string, data []interface{})
	Info(msg string, data []interface{})
	Warn(msg string, data []interface{})
	Error(msg string, data []interface{})
	Panic(msg string, data []interface{})
	Fatal(msg string, data []interface{})
}

type StandardLogger

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

func (*StandardLogger) Debug

func (s *StandardLogger) Debug(msg string, data []interface{})

func (*StandardLogger) Error

func (s *StandardLogger) Error(msg string, data []interface{})

func (*StandardLogger) Fatal

func (s *StandardLogger) Fatal(msg string, data []interface{})

func (*StandardLogger) Info

func (s *StandardLogger) Info(msg string, data []interface{})

func (*StandardLogger) Initialize

func (s *StandardLogger) Initialize(conf *Config)

func (*StandardLogger) Panic

func (s *StandardLogger) Panic(msg string, data []interface{})

func (*StandardLogger) SetLevel

func (s *StandardLogger) SetLevel(lvl int8)

func (*StandardLogger) Warn

func (s *StandardLogger) Warn(msg string, data []interface{})

Directories

Path Synopsis
Package rotate provides a rolling logger.
Package rotate provides a rolling logger.

Jump to

Keyboard shortcuts

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