log

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: BSD-2-Clause Imports: 3 Imported by: 2

Documentation

Overview

package log provides a simple logger with leveled log messages.

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

Output is written to the default logger.

Example
log.SetOutput(os.Stdout)
log.SetFlags(0) // To disable date and time output.
err := SetLevelFromString("warning")
if err != nil {
	panic(err)
}

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 SetLevel

func SetLevel(lv level)

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

func SetLevelFromString added in v0.1.1

func SetLevelFromString(levelName string) error

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