logger

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

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 8 Imported by: 2

README

logger Build Status

Simple colored logger

To install:

go get github.com/govlas/logger

Dependencies:

go get github.com/fatih/color
go get github.com/shiena/ansicolor

See docs for usage

Documentation

Overview

Package logger provides collection of loggin functions with colored output and stack frames

Index

Constants

View Source
const (
	// FileNameNo indicates to no print filename
	FileNameNo int = iota
	// FileNameShort indicates to print short filename
	FileNameShort
	// FileNameLong indicates to print full filename
	FileNameLong
)

Variables

View Source
var (

	// InfoPrefix is text prefix for info log
	InfoPrefix = "INFO"
	// WarnPrefix is text prefix for warning log
	WarnPrefix = "WARN"
	// ErrPrefix is text prefix for error log
	ErrPrefix = " ERR"
	// DebugPrefix is text prefix for debug log
	DebugPrefix = " DEB"
)

Functions

func Debug

func Debug(message string, v ...interface{})

Debug prints debug log (blue if colored)

func DisableBTrace

func DisableBTrace()

DisableBTrace disables backtrace

func DisableColored

func DisableColored()

DisableColored disables colored output

func DisableDebug

func DisableDebug()

DisableDebug disables debug logs

func EnableBTrace

func EnableBTrace()

EnableBTrace enables backtrace for warnings and errors

func EnableColored

func EnableColored()

EnableColored enables colored output

func EnableDebug

func EnableDebug()

EnableDebug enables debug logs

func Error

func Error(message string, v ...interface{})

Error prints error log (red if colored)

func ErrorErr

func ErrorErr(err error) bool

ErrorErr prints err as error log and returns true if err!=nil

func Fatal

func Fatal(message string, v ...interface{})

Fatal prints error log and finish proccess by os.Exit(1)

func FatalErr

func FatalErr(err error)

FatalErr prints err as fatal log

func Info

func Info(message string, v ...interface{})

Info prints info log (green if colored)

func JSONDebug

func JSONDebug(a interface{})

JSONDebug prints object in json format

func Panic

func Panic(message string, v ...interface{})

Panic prints error log and call panic

func PanicRecover

func PanicRecover()

PanicRecover recovers panic an print error message

func SetFileName

func SetFileName(fn int)

SetFileName sets flag for print ceurrent file name in log

func SetOut

func SetOut(out io.Writer)

SetOut set writer fo print logs. Default writer is os.Stdout

func Warning

func Warning(message string, v ...interface{})

Warning prints warning log (yellow if colored)

func WarningErr

func WarningErr(err error) bool

WarningErr prints err as warning log and returns true if err!=nil

Types

This section is empty.

Jump to

Keyboard shortcuts

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