log

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: BSD-2-Clause Imports: 4 Imported by: 6

Documentation

Overview

package log provides a simple logger with leveled log messages.

  • DebugLevel (highest verbosity)
  • InfoLevel
  • WarningLevel
  • ErrorLevel
  • FatalLevel (lowest verbosity)

Output is by default written to STDERR. A different output can be specified. Dates and terminal colors can be turned on.

Example
SetOutput(os.Stdout)
SetLevel(WarningLevel)
SetDate(false)
SetColor(false)

Debug("some debug number: %d\n", 10)
Info("some info number: %d\n", 20)
Warning("some warning number: %d\n", 30)
Error("some error number: %d\n", 40)
Output:

[WARN] some warning number: 30
[ERRO] some error number: 40

Index

Examples

Constants

View Source
const (
	DebugLevel   level = iota // DebugLevel logs all messages
	InfoLevel                 // InfoLevel logs info messages and and above
	WarningLevel              // WarningLevel logs warning messages and above
	ErrorLevel                // ErrorLevel logs error messages and above
	FatalLevel                // FatalLevel only logs fatal messages
)

Variables

This section is empty.

Functions

func Debug

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

func Error

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

func Fatal

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

func Info

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

func SetColor

func SetColor(ok bool)

SetColor (un)sets terminal colors.

func SetDate

func SetDate(ok bool)

SetDate (un)sets date output.

func SetLevel

func SetLevel(lv level)

SetLevel sets the logging level. Available options: DebugLevel, InfoLevel, WarningLevel, ErrorLevel, FatalLevel.

func SetOutput

func SetOutput(writer io.Writer)

SetOutput sets the logging output to a particular writer.

func Warning

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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