Breaking: Rename functions in Printf
format
This commit is contained in:
parent
548575b4a7
commit
eb305d5e40
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v2.4.0
|
rev: v3.4.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
@ -12,5 +12,4 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: go-fmt
|
- id: go-fmt
|
||||||
- id: go-imports
|
- id: go-imports
|
||||||
# - id: gometalinter
|
- id: golangci-lint
|
||||||
# - id: golangci-lint
|
|
||||||
|
42
README.md
42
README.md
@ -35,29 +35,32 @@ Also provided are a few simple methods for handling returned `error` variables,
|
|||||||
|
|
||||||
FUNCTIONS
|
FUNCTIONS
|
||||||
|
|
||||||
func Debug(format string, v ...interface{})
|
func Debugf(format string, v ...interface{})
|
||||||
Debug will log with a DEBUG prefix if DebugLevel is se
|
Debugf will log with a DEBUG prefix if DebugLevel is se
|
||||||
|
|
||||||
func Error(format string, v ...interface{})
|
func Errorf(format string, v ...interface{})
|
||||||
Error will log with a ERROR prefix
|
Errorf will log with a ERROR prefix
|
||||||
|
|
||||||
func Fatal(format string, v ...interface{})
|
func Fatalf(format string, v ...interface{})
|
||||||
Fatal will log with a ERROR prefix followed by exit(1)
|
Fatalf will log with a ERROR prefix followed by exit(1)
|
||||||
|
|
||||||
func FatalOnErr(err error, format string, v ...interface{})
|
func Infof(format string, v ...interface{})
|
||||||
FatalOnErr if error provided, will log out details of an error and exi
|
Infof formats logs with an INFO prefix
|
||||||
|
|
||||||
func Info(format string, v ...interface{})
|
func Logf(format string, v ...interface{})
|
||||||
Info formats logs with an INFO prefix
|
Logf formats logs directly to the main logger
|
||||||
|
|
||||||
func Log(format string, v ...interface{})
|
func OnErrFatalf(err error, format string, v ...interface{})
|
||||||
Log formats logs directly to the main logger
|
OnErrFatalf if error provided, will log out details of an error and exi
|
||||||
|
|
||||||
func Panic(format string, v ...interface{})
|
func OnErrPanicf(err error, format string, v ...interface{})
|
||||||
Panic will log with a ERROR prefix followed by panic()
|
OnErrPanicf if error provided, will log out details of an error and exi
|
||||||
|
|
||||||
func PanicOnErr(err error, format string, v ...interface{})
|
func OnErrWarnf(err error, format string, v ...interface{})
|
||||||
PanicOnErr if error provided, will log out details of an error and exi
|
OnErrWarnf if error provided, will provide a warning if an error is provided
|
||||||
|
|
||||||
|
func Panicf(format string, v ...interface{})
|
||||||
|
Panicf will log with a ERROR prefix followed by panic()
|
||||||
|
|
||||||
func SetFlags(flag int)
|
func SetFlags(flag int)
|
||||||
SetFlags allows changing the logger flags using flags found in `log`
|
SetFlags allows changing the logger flags using flags found in `log`
|
||||||
@ -65,8 +68,5 @@ Also provided are a few simple methods for handling returned `error` variables,
|
|||||||
func SetOutput(w io.Writer)
|
func SetOutput(w io.Writer)
|
||||||
SetOutput allows changing the output of all loggers
|
SetOutput allows changing the output of all loggers
|
||||||
|
|
||||||
func WarnOnErr(err error, format string, v ...interface{})
|
func Warningf(format string, v ...interface{})
|
||||||
WarnOnErr if error provided, will provide a warning if an error is provided
|
Warningf will log with a WARNING prefix
|
||||||
|
|
||||||
func Warning(format string, v ...interface{})
|
|
||||||
Warning will log with a WARNING prefix
|
|
||||||
|
41
slog.go
41
slog.go
@ -49,62 +49,63 @@ func SetOutput(w io.Writer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log formats logs directly to the main logger
|
// Logf formats logs directly to the main logger
|
||||||
func Log(format string, v ...interface{}) {
|
func Logf(format string, v ...interface{}) {
|
||||||
log.Printf(format, v...)
|
log.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug will log with a DEBUG prefix if DebugLevel is set
|
// Debugf will log with a DEBUG prefix if DebugLevel is set
|
||||||
func Debug(format string, v ...interface{}) {
|
func Debugf(format string, v ...interface{}) {
|
||||||
if !DebugLevel {
|
if !DebugLevel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
LoggerDebug.Printf(format, v...)
|
LoggerDebug.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info formats logs with an INFO prefix
|
// Infof formats logs with an INFO prefix
|
||||||
func Info(format string, v ...interface{}) {
|
func Infof(format string, v ...interface{}) {
|
||||||
LoggerInfo.Printf(format, v...)
|
LoggerInfo.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning will log with a WARNING prefix
|
// Warningf will log with a WARNING prefix
|
||||||
func Warning(format string, v ...interface{}) {
|
func Warningf(format string, v ...interface{}) {
|
||||||
LoggerWarning.Printf(format, v...)
|
LoggerWarning.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error will log with a ERROR prefix
|
// Errorf will log with a ERROR prefix
|
||||||
func Error(format string, v ...interface{}) {
|
func Errorf(format string, v ...interface{}) {
|
||||||
LoggerError.Printf(format, v...)
|
LoggerError.Printf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fatal will log with a ERROR prefix followed by exit(1)
|
// Fatalf will log with a ERROR prefix followed by exit(1)
|
||||||
func Fatal(format string, v ...interface{}) {
|
func Fatalf(format string, v ...interface{}) {
|
||||||
LoggerError.Fatalf(format, v...)
|
LoggerError.Fatalf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Panic will log with a ERROR prefix followed by panic()
|
// Panicf will log with a ERROR prefix followed by panic()
|
||||||
func Panic(format string, v ...interface{}) {
|
func Panicf(format string, v ...interface{}) {
|
||||||
LoggerError.Panicf(format, v...)
|
LoggerError.Panicf(format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WarnOnErr if error provided, will provide a warning if an error is provided
|
// OnErrWarnf if error provided, will provide a warning if an error is provided
|
||||||
func WarnOnErr(err error, format string, v ...interface{}) {
|
func OnErrWarnf(err error, format string, v ...interface{}) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LoggerWarning.Printf(format, v...)
|
LoggerWarning.Printf(format, v...)
|
||||||
LoggerError.Print(err)
|
LoggerError.Print(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FatalOnErr if error provided, will log out details of an error and exit
|
// OnErrFatalf if error provided, will log out details of an error and exit
|
||||||
func FatalOnErr(err error, format string, v ...interface{}) {
|
func OnErrFatalf(err error, format string, v ...interface{}) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LoggerError.Printf(format, v...)
|
LoggerError.Printf(format, v...)
|
||||||
LoggerError.Fatal(err)
|
LoggerError.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PanicOnErr if error provided, will log out details of an error and exit
|
// OnErrPanicf if error provided, will log out details of an error and exit
|
||||||
func PanicOnErr(err error, format string, v ...interface{}) {
|
func OnErrPanicf(err error, format string, v ...interface{}) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LoggerError.Printf(format, v...)
|
LoggerError.Printf(format, v...)
|
||||||
LoggerError.Panic(err)
|
LoggerError.Panic(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user