stump

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT, MIT Imports: 4 Imported by: 1

README

Stump

A simple log library, for when you don't really care to have super fancy logs.

Stump has four main log functions, Log, VLog, Error and Fatal.

Log is a basic log that always is shown.

VLog is only shown when stump.Verbose is set to true.

Error prints a prefix of ERROR: before your log message, the prefix is configurable by setting stump.ErrorPrefix.

Fatal is an error log that also calls os.Exit right afterwards.

Installation

$ go get -u github.com/whyrusleeping/stump

Usage

import "github.com/whyrusleeping/stump"

func main() {
	stump.Log("Hello World!")

	name := GetName()
	stump.Log("My name is %s, do you like it?", name)

	err := DoThing()
	if err != nil {
		stump.Error(err)
		// or
		stump.Error("Got an error doing thing: ", err)
		// or
		stump.Error("Got error '%s' doing thing.", err)
	}

	err = DoImportantThing()
	if err != nil {
		Fatal(err)
	}
}

Tips

While generally frowned upon, I like importing stump into my packages namespace like so:

import . "github.com/whyrusleeping/stump"

This allows you to call all the logging functions without the package prefix. (eg. just Log("hello") instead of stump.Log("hello"))

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOut io.Writer = os.Stdout
View Source
var ErrorPrefix = "ERROR: "
View Source
var LogOut io.Writer = os.Stdout
View Source
var Verbose bool

Functions

func Error

func Error(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Log

func Log(args ...interface{})

func VLog

func VLog(args ...interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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