cli: Refactor out log to the top level
Remove some cruft at the same time.
This commit is contained in:
@@ -40,6 +40,7 @@ import (
|
||||
func Hello(program, version string, flags Flags) {
|
||||
var start = time.Now().UnixNano()
|
||||
|
||||
// TODO: Move these log package initialization steps to the top main.go?
|
||||
logFlags := log.LstdFlags
|
||||
if flags.Debug {
|
||||
logFlags = logFlags + log.Lshortfile
|
||||
@@ -55,5 +56,5 @@ func Hello(program, version string, flags Flags) {
|
||||
fmt.Println(fmt.Sprintf("This is: %s, version: %s", program, version))
|
||||
fmt.Println("Copyright (C) 2013-2024+ James Shubin and the project contributors")
|
||||
fmt.Println("Written by James Shubin <james@shubin.ca> and the project contributors")
|
||||
log.Printf("main: start: %v", start)
|
||||
flags.Logf("main: start: %v", start)
|
||||
}
|
||||
|
||||
@@ -54,10 +54,9 @@ func CliParseError(err error) error {
|
||||
}
|
||||
|
||||
// Flags are some constant flags which are used throughout the program.
|
||||
// TODO: Unify this with Debug and Logf ?
|
||||
type Flags struct {
|
||||
Debug bool // add additional log messages
|
||||
Verbose bool // add extra log message output
|
||||
Debug bool // add additional log messages
|
||||
Logf func(format string, v ...interface{})
|
||||
}
|
||||
|
||||
// Data is a struct of values that we usually pass to the main CLI function.
|
||||
|
||||
Reference in New Issue
Block a user