Files
zeekayandHanzo Dev 85d7501b1f Build on Go 1.27
go fix applied the modernizers. One rewrite it got wrong is corrected here: a
reverse loop over runes became a range over slices.Backward that bound the index
and the value to the SAME name, which does not compile and would have compared a
rune to an index if it had. The value gets its own name.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 06:18:28 -07:00

45 lines
708 B
Go

package cli
import (
"fmt"
logpkg "log"
"os"
)
// Log represents the logger
type Log struct {
verbose bool
}
// Printf prints out formatted string into a log
func (l *Log) Printf(format string, v ...any) {
if l.verbose {
logpkg.Printf(format, v...)
} else {
fmt.Fprintf(os.Stderr, format, v...)
}
}
// Println prints out args into a log
func (l *Log) Println(args ...any) {
if l.verbose {
logpkg.Println(args...)
} else {
fmt.Fprintln(os.Stderr, args...)
}
}
// Verbose shows if verbose print enabled
func (l *Log) Verbose() bool {
return l.verbose
}
func (l *Log) fatal(args ...any) {
l.Println(args...)
os.Exit(1)
}
func (l *Log) fatalErr(err error) {
l.fatal("error:", err)
}