Skip to content

Commit

Permalink
klog.Fatal: document behavior and alternatives
Browse files Browse the repository at this point in the history
After reverting #79 users who want the
full dump of all goroutines can still get it by calling

   github.com/go-logr/lib.Backtrace(lib.BacktraceAll(true)).
  • Loading branch information
pohly committed Jun 13, 2022
1 parent 907ca44 commit 1a2fab8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion klog.go
Expand Up @@ -1589,7 +1589,18 @@ func ErrorSDepth(depth int, err error, msg string, keysAndValues ...interface{})
}

// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs,
// including a stack trace of all running goroutines, then calls OsExit(255).
// prints stack trace(s), then calls OsExit(255).
//
// Stderr only receives a dump of the current goroutine's stack trace. Log files,
// if there are any, receive a dump of the stack traces in all goroutines.
//
// Callers who want more control over handling of fatal events may instead use a
// combination of different functions:
// - some info or error logging function, optionally with a stack trace
// value generated by github.com/go-logr/lib/dbg.Backtrace
// - Flush to flush pending log data
// - panic, os.Exit or returning to the caller with an error
//
// Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func Fatal(args ...interface{}) {
logging.print(severity.FatalLog, logging.logger, logging.filter, args...)
Expand Down

0 comments on commit 1a2fab8

Please sign in to comment.