Add doc in default implementation fatal functions on os.Exit() (#1365)

This commit is contained in:
Menghan Li
2017-07-21 09:39:31 -07:00
committed by dfawley
parent 2bb3182589
commit b34c88b087
2 changed files with 12 additions and 3 deletions

View File

@ -99,6 +99,7 @@ func Errorln(args ...interface{}) {
// It calls os.Exit() with exit code 1.
func Fatal(args ...interface{}) {
logger.Fatal(args...)
// Make sure fatal logs will exit.
os.Exit(1)
}
@ -106,6 +107,7 @@ func Fatal(args ...interface{}) {
// It calles os.Exit() with exit code 1.
func Fatalf(format string, args ...interface{}) {
logger.Fatalf(format, args...)
// Make sure fatal logs will exit.
os.Exit(1)
}
@ -113,6 +115,7 @@ func Fatalf(format string, args ...interface{}) {
// It calle os.Exit()) with exit code 1.
func Fatalln(args ...interface{}) {
logger.Fatalln(args...)
// Make sure fatal logs will exit.
os.Exit(1)
}

View File

@ -62,13 +62,16 @@ type LoggerV2 interface {
// Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
Errorf(format string, args ...interface{})
// Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print.
// This function should call os.Exit() with a non-zero exit code.
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
// Implementations may also call os.Exit() with a non-zero exit code.
Fatal(args ...interface{})
// Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
// This function should call os.Exit() with a non-zero exit code.
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
// Implementations may also call os.Exit() with a non-zero exit code.
Fatalln(args ...interface{})
// Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf.
// This function should call os.Exit() with a non-zero exit code.
// gRPC ensures that all Fatal logs will exit with os.Exit(1).
// Implementations may also call os.Exit() with a non-zero exit code.
Fatalf(format string, args ...interface{})
// V reports whether verbosity level l is at least the requested verbose level.
V(l int) bool
@ -189,14 +192,17 @@ func (g *loggerT) Errorf(format string, args ...interface{}) {
func (g *loggerT) Fatal(args ...interface{}) {
g.m[fatalLog].Fatal(args...)
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}
func (g *loggerT) Fatalln(args ...interface{}) {
g.m[fatalLog].Fatalln(args...)
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}
func (g *loggerT) Fatalf(format string, args ...interface{}) {
g.m[fatalLog].Fatalf(format, args...)
// No need to call os.Exit() again because log.Logger.Fatal() calls os.Exit().
}
func (g *loggerT) V(l int) bool {