log

import "go.science.ru.nl/log"

Overview

Package log implements a small wrapper around the std lib log package. It implements log levels by prefixing the logs with [INFO], [DEBUG], [WARNING] or [ERROR]. All output goes to standard error. It is expected the logging flows into journald; journald adds its own timestamp. So timestamping logs is disabled here.

Examples:

log.Info("this is some logging"), will log on the Info level.
log.Debug("this is debug output"), will log in the Debug level, etc.

Index

Package files

log.go

Variables

var D = &d{}

D controls whether we should output debug logs. If true, we do. Once set it can be unset with Clear.

func Debug

func Debug(v ...interface{})

Debug is equivalent to log.Print(), but prefixed with “[DEBUG] “. It only outputs something if D is true.

func Debugf

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

Debugf is equivalent to log.Printf(), but prefixed with “[DEBUG] “. It only outputs something if D is true.

func Discard

func Discard()

Discard sets the log output to /dev/null.

func Error

func Error(v ...interface{})

Error is equivalent to log.Print, but prefixed with “[ERROR] “.

func Errorf

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

Errorf is equivalent to log.Printf, but prefixed with “[ERROR] “.

func Fatal

func Fatal(v ...interface{})

Fatal is equivalent to log.Print, but prefixed with “[FATAL] “, and calling os.Exit(1).

func Fatalf

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

Fatalf is equivalent to log.Printf, but prefixed with “[FATAL] “, and calling os.Exit(1)

func Info

func Info(v ...interface{})

Info is equivalent to log.Print, but prefixed with “[INFO] “.

func Infof

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

Infof is equivalent to log.Printf, but prefixed with “[INFO] “.

func SetSuffix

func SetSuffix(s string)

SetSuffix set a possible suffix string that is printed after the log level. An extra space is added to this string. Use the empty string to clear.

func Warning

func Warning(v ...interface{})

Warning is equivalent to log.Print, but prefixed with “[WARNING] “.

func Warningf

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

Warningf is equivalent to log.Printf, but prefixed with “[WARNING] “.