Add Fatal and Panic
This commit is contained in:
parent
1744abb8b4
commit
548575b4a7
@ -41,6 +41,9 @@ Also provided are a few simple methods for handling returned `error` variables,
|
|||||||
func Error(format string, v ...interface{})
|
func Error(format string, v ...interface{})
|
||||||
Error will log with a ERROR prefix
|
Error will log with a ERROR prefix
|
||||||
|
|
||||||
|
func Fatal(format string, v ...interface{})
|
||||||
|
Fatal will log with a ERROR prefix followed by exit(1)
|
||||||
|
|
||||||
func FatalOnErr(err error, format string, v ...interface{})
|
func FatalOnErr(err error, format string, v ...interface{})
|
||||||
FatalOnErr if error provided, will log out details of an error and exi
|
FatalOnErr if error provided, will log out details of an error and exi
|
||||||
|
|
||||||
@ -50,6 +53,9 @@ Also provided are a few simple methods for handling returned `error` variables,
|
|||||||
func Log(format string, v ...interface{})
|
func Log(format string, v ...interface{})
|
||||||
Log formats logs directly to the main logger
|
Log formats logs directly to the main logger
|
||||||
|
|
||||||
|
func Panic(format string, v ...interface{})
|
||||||
|
Panic will log with a ERROR prefix followed by panic()
|
||||||
|
|
||||||
func PanicOnErr(err error, format string, v ...interface{})
|
func PanicOnErr(err error, format string, v ...interface{})
|
||||||
PanicOnErr if error provided, will log out details of an error and exi
|
PanicOnErr if error provided, will log out details of an error and exi
|
||||||
|
|
||||||
|
22
slog.go
22
slog.go
@ -54,6 +54,14 @@ func Log(format string, v ...interface{}) {
|
|||||||
log.Printf(format, v...)
|
log.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug will log with a DEBUG prefix if DebugLevel is set
|
||||||
|
func Debug(format string, v ...interface{}) {
|
||||||
|
if !DebugLevel {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
LoggerDebug.Printf(format, v...)
|
||||||
|
}
|
||||||
|
|
||||||
// Info formats logs with an INFO prefix
|
// Info formats logs with an INFO prefix
|
||||||
func Info(format string, v ...interface{}) {
|
func Info(format string, v ...interface{}) {
|
||||||
LoggerInfo.Printf(format, v...)
|
LoggerInfo.Printf(format, v...)
|
||||||
@ -69,12 +77,14 @@ func Error(format string, v ...interface{}) {
|
|||||||
LoggerError.Printf(format, v...)
|
LoggerError.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug will log with a DEBUG prefix if DebugLevel is set
|
// Fatal will log with a ERROR prefix followed by exit(1)
|
||||||
func Debug(format string, v ...interface{}) {
|
func Fatal(format string, v ...interface{}) {
|
||||||
if !DebugLevel {
|
LoggerError.Fatalf(format, v...)
|
||||||
return
|
}
|
||||||
}
|
|
||||||
LoggerDebug.Printf(format, v...)
|
// Panic will log with a ERROR prefix followed by panic()
|
||||||
|
func Panic(format string, v ...interface{}) {
|
||||||
|
LoggerError.Panicf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarnOnErr if error provided, will provide a warning if an error is provided
|
// WarnOnErr if error provided, will provide a warning if an error is provided
|
||||||
|
Loading…
Reference in New Issue
Block a user