logtools

package module
v0.0.0-...-3d23378 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2017 License: MIT Imports: 6 Imported by: 4

README

logtools

This go package is a wrapper package for the amazing logrus logging package. It provides an Initialize() function that is called automatically on first use. The initializer sets a sane default log formatter. Currently the implemenation defaults to setting the loglevel to debug. If you don't like this, then call Initialize() explizitly and afterwards set the logging level yourself by using SetLevel(InfoLevel) (or whichever level you want).

Usage

go get github.com/ms-xy/logtools
import (
  "github.com/ms-xy/logtools"
)

func main() {
  logtools.Info("Some informative log message")
  logtools.WithFields(logtools.Fields{
    "key": "value",
  }).Warn("More informative with the WithFields Wrapper of logrus")
}

To set the loglevel explicitly:

func main() {
  logtools.Initialize()
  logtools.SetLevel(logtools.WarnLevel)
  logtools.Info("Some informative log message") // <- does not print anymore
  logtools.WithFields(logtools.Fields{
    "key": "value",
  }).Warn("More informative with the WithFields Wrapper of logrus")
}

License

MIT - just as the logrus package.

Documentation

Index

Constants

View Source
const (
	DebugLevel = logrus.DebugLevel
	InfoLevel  = logrus.InfoLevel
	WarnLevel  = logrus.WarnLevel
	ErrorLevel = logrus.ErrorLevel
	FatalLevel = logrus.FatalLevel
	PanicLevel = logrus.PanicLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug(i ...interface{})

func Debugf

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

func Error

func Error(i ...interface{})

func Errorf

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

func Fatal

func Fatal(i ...interface{})

func Fatalf

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

func Info

func Info(i ...interface{})

func Infof

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

func Initialize

func Initialize()

func Log

func Log(i ...interface{})

func Logf

func Logf(format string, i ...interface{})

func Panic

func Panic(i ...interface{})

func Panicf

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

func Prefix

func Prefix() *logrus.Entry

func SetLevel

func SetLevel(level logrus.Level)

func Warn

func Warn(i ...interface{})

func Warnf

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

func WithFields

func WithFields(fields Fields) *logrus.Entry

Types

type Fields

type Fields logrus.Fields

Jump to

Keyboard shortcuts

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