log

package
v0.0.0-...-91a82d4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: LGPL-3.0 Imports: 10 Imported by: 21

README

log

use logrus support json format log

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Format: "text",
	Formatter: &logrus.TextFormatter{
		TimestampFormat: "2006-01-02 15:04:05.999",
		FullTimestamp:   true,
	},
	Level:  "debug",
	Output: os.Stderr,
}

DefaultConfig default config

Functions

func AddHook

func AddHook(hook logrus.Hook)

AddHook adds a hook to the standard logger hooks.

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug on the standard logger.

func Debugf

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

Debugf logs a message at level Debug on the standard logger.

func Error

func Error(args ...interface{})

Error logs a message at level Error on the standard logger.

func Errorf

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

Errorf logs a message at level Error on the standard logger.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal on the standard logger.

func Fatalf

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

Fatalf logs a message at level Fatal on the standard logger.

func GetLevel

func GetLevel() logrus.Level

GetLevel returns the standard logger level.

func Info

func Info(args ...interface{})

Info logs a message at level Info on the standard logger.

func Infof

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

Infof logs a message at level Info on the standard logger.

func Panic

func Panic(args ...interface{})

Panic logs a message at level Panic on the standard logger.

func Panicf

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

Panicf logs a message at level Panic on the standard logger.

func Print

func Print(args ...interface{})

Print logs a message at level Info on the standard logger.

func Printf

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

Printf logs a message at level Info on the standard logger.

func SetConfig

func SetConfig(cfg *Config)

SetConfig sets the standard logger formatter.

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn on the standard logger.

func Warnf

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

Warnf logs a message at level Warn on the standard logger.

func Warning

func Warning(args ...interface{})

Warning logs a message at level Warn on the standard logger.

func Warningf

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

Warningf logs a message at level Warn on the standard logger.

Types

type CallerHook

type CallerHook struct {
}

CallerHook represents a caller hook of logrus

func (*CallerHook) Fire

func (hook *CallerHook) Fire(entry *logrus.Entry) error

Fire adds a callers field in logger instance

func (*CallerHook) Levels

func (hook *CallerHook) Levels() []logrus.Level

Levels returns support levels

type Config

type Config struct {
	Format    string `mapstructure:"log-format"`
	Formatter logrus.Formatter
	Level     string `mapstructure:"log-level"`
	Output    io.Writer
}

Config log config

type Logger

type Logger interface {
	Debug(args ...interface{})
	Print(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Panic(args ...interface{})
	Fatal(args ...interface{})

	Debugf(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger wrappers access to logger instance

func New

func New(args ...interface{}) (Logger, error)

New returns an standard logger or a file system logger according the filename

Jump to

Keyboard shortcuts

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