Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize trace references for debug/trace output #305

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions cli/internal/message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func init() {
}
}

func debugPrinter() *pterm.PrefixPrinter {
return pterm.Debug.WithShowLineNumber(logLevel > 2).WithLineNumberOffset(2)
func debugPrinter(offset int) *pterm.PrefixPrinter {
return pterm.Debug.WithShowLineNumber(logLevel > 2).WithLineNumberOffset(offset)
}

func errorPrinter() *pterm.PrefixPrinter {
return pterm.Error.WithShowLineNumber(logLevel > 2).WithLineNumberOffset(2)
func errorPrinter(offset int) *pterm.PrefixPrinter {
return pterm.Error.WithShowLineNumber(logLevel > 2).WithLineNumberOffset(offset)
}

func SetLogLevel(lvl LogLevel) {
Expand All @@ -62,19 +62,20 @@ func GetLogLevel() LogLevel {
}

func Debug(payload ...interface{}) {
debugPrinter().Println(payload...)
debugPrinter(1).Println(payload...)
}

func Debugf(format string, a ...interface{}) {
debugPrinter().Printfln(format, a...)
debugPrinter(2).Printfln(format, a...)
}

func Error(err interface{}, message string) {
Errorf(err, message)
debugPrinter(1).Println(err)
Warnf(message)
}

func Errorf(err interface{}, format string, a ...interface{}) {
Debug(err)
debugPrinter(1).Println(err)
Warnf(format, a...)
}

Expand All @@ -88,15 +89,15 @@ func Warnf(format string, a ...interface{}) {
}

func Fatal(err interface{}, message string) {
Debug(err)
errorPrinter().Println(message)
debugPrinter(1).Println(err)
errorPrinter(1).Println(message)
os.Exit(1)
}

func Fatalf(err interface{}, format string, a ...interface{}) {
Debug(err)
debugPrinter(1).Println(err)
message := paragraph(format, a...)
errorPrinter().Println(message)
errorPrinter(1).Println(message)
os.Exit(1)
}

Expand Down