logger

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 5 Imported by: 8

README

Simple log package

Simple abstraction for logs using Logrus.

E.g.:

  • Log message:
logger.Info("Loading Observer API")
  • Log message with params:
logger.Info("Running application", logger.Params{"bind": bind})
  • Fatal with error:
logger.Fatal("Application failed", err)
  • The method parameters don't have a sort. You just need to pass them to the method:
logger.Fatal(err, "Application failed")
  • Create a simple error log:
logger.Error(err)
  • Create an error log with a message:
logger.Error("Failed to initialize API", err)
  • Create an error log, with error, message, and params:
p := logger.Params{
	"platform": handle,
	"coin":     platform.Coin(),
}
err := platform.Init()
if err != nil {
	logger.Error("Failed to initialize API", err, p)
}
  • Debug log:
logger.Debug("Loading Observer API")
// OR 
logger.Debug("Loading Observer API", logger.Params{"bind": bind})
  • Warning log:
logger.Warn("Warning", err)
// OR 
logger.Warn(err, "Warning")
// OR 
logger.Warn("Warning", err, logger.Params{"bind": bind})

Documentation

Index

Constants

View Source
const (
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = LogLevel(log.WarnLevel)
	// InfoLevel level. General operational entries about what's going on inside the application.
	InfoLevel = LogLevel(log.InfoLevel)
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = LogLevel(log.DebugLevel)
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug log a debug message

func Error

func Error(args ...interface{})

Error log an error message

func Fatal

func Fatal(args ...interface{})

Fatal log a fatal message

func Info

func Info(args ...interface{})

Info log an info message

func Panic

func Panic(args ...interface{})

Panic trigger a app panic with message

func SetLogLevel

func SetLogLevel(level LogLevel)

SetLogLevel sets the standard logger level.

func Warn

func Warn(args ...interface{})

Warn log a warning message

Types

type LogLevel

type LogLevel uint32

type Params

type Params map[string]interface{}

Jump to

Keyboard shortcuts

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