smaug

package module
v0.0.0-...-7d9236b Latest Latest
Warning

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

Go to latest
Published: May 25, 2014 License: MIT Imports: 2 Imported by: 0

README

smaug

Package smaug implements a simple leveled logging package.

There are four logging levels: DEBUG, INFO, WARN and ERROR. And four corresponding loggers: Debug, Info, Warn and Error.

Each logger provides four logging methods: Dump, Print, Printf and Println.

Dump is a pretty printer.

Print, Printf and Println wrap the equivalent functions in the standard library log package.

// set our log level to INFO
smaug.Level = smaug.INFO

// logging through Debug will not create ouptut
smaug.Debug.Print("you won't see me")

// logging through Info, Warn and will create ouptut
smaug.Info.Print("you will see me")
smaug.Warn.Print("you will see me")
smaug.Error.Print("you will see me")

Package smaug also contains convenience methods for single error handling, where you're okay with panicing or exiting your process.

// this will call log.Fatal:
smaug.FatalIf(func () error {
	return errors.New("oh no!")
})

// this will call log.Panic:
smaug.PanicIf(func () error {
	return errors.New("oh no!")
})

Overall, no big shakes. Just a lighweight wrapper around other packages.

Documentation

Index

Constants

View Source
const (
	DEBUG level = iota
	INFO
	WARN
	ERROR
)
View Source
const (
	Debug logger = iota
	Info
	Warn
	Error
)

Variables

View Source
var (
	Fatal   = log.Fatal
	Fatalf  = log.Fatalf
	Fatalln = log.Fatalln
)
View Source
var (
	Panic   = log.Panic
	Panicf  = log.Panicf
	Panicln = log.Panicln
)
View Source
var Level level = DEBUG

Functions

func FatalIf

func FatalIf(err error)

func FatalIff

func FatalIff(err error, format string, v ...interface{})

func PanicIf

func PanicIf(err error)

func PanicIff

func PanicIff(err error, format string, v ...interface{})

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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