-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a logger for everyting we used to Printf/Fatalf to the console: this makes handling Quiet mode much easier.
- Loading branch information
Showing
7 changed files
with
84 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package console | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// Logger implements Logger interface, display logs on stdout | ||
type Logger struct { | ||
Quiet bool | ||
} | ||
|
||
// Infof displays a formated string, honoring the Quiet config setting | ||
func (l *Logger) Infof(format string, v ...interface{}) { | ||
if l.Quiet { | ||
return | ||
} | ||
fmt.Printf(format, v...) | ||
} | ||
|
||
// Fatal displays a message then exit the program | ||
func (l *Logger) Fatal(v ...interface{}) { | ||
fmt.Print(v...) | ||
os.Exit(1) | ||
} | ||
|
||
// Fatalf displays a formated string then exit the program | ||
func (l *Logger) Fatalf(format string, v ...interface{}) { | ||
fmt.Printf(format, v...) | ||
os.Exit(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package log | ||
|
||
// Logger handle logs, ideally honoring the Quiet config parameter | ||
type Logger interface { | ||
Infof(format string, v ...interface{}) | ||
Fatalf(format string, v ...interface{}) | ||
Fatal(v ...interface{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters