From 0c80cca674931c9dbfc69c25df24d53abbdd63a9 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 5 Jun 2016 14:26:16 +0200 Subject: toggledlog: convert remaing naked fmt.Print* Several fatal errors were just printed to stdout, which meant they were invisible when running the test suite. Fix this by introducing toggledlog.Fatal and convert as follows: Fatal errors -> toggledlog.Fatal Warnings -> toggledlog.Warn Password prompts -> fmt.Fprintf --- internal/toggledlog/log.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'internal/toggledlog') diff --git a/internal/toggledlog/log.go b/internal/toggledlog/log.go index 7f437c8..23d7347 100644 --- a/internal/toggledlog/log.go +++ b/internal/toggledlog/log.go @@ -49,18 +49,24 @@ func (l *toggledLogger) Println(v ...interface{}) { } } -// As defined by http://elinux.org/Debugging_by_printing#Log_Levels // Debug messages +// Can be enabled by passing "-d" var Debug *toggledLogger -// Informational message e.g. startup information +// Informational message +// Can be disabled by passing "-q" var Info *toggledLogger -// A warning, meaning nothing serious by itself but might indicate problems +// A warning, meaning nothing serious by itself but might indicate problems. +// Passing "-wpanic" will make this function panic after printing the message. var Warn *toggledLogger +// Fatal error, we are about to exit +var Fatal *toggledLogger + func init() { Debug = &toggledLogger{false, false, log.New(os.Stdout, "", 0)} Info = &toggledLogger{true, false, log.New(os.Stdout, "", 0)} Warn = &toggledLogger{true, false, log.New(os.Stderr, "", 0)} + Fatal = &toggledLogger{true, false, log.New(os.Stderr, "", 0)} } -- cgit v1.2.3