Documentation ¶
Overview ¶
Package slog is a super simple logger that allows a few convenience methods for handling debug vs warning/error logs. It also adds a few conveniences for handling errors.
Index ¶
- Variables
- func Debugf(format string, v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Infof(format string, v ...interface{})
- func Logf(format string, v ...interface{})
- func OnErrFatalf(err error, format string, v ...interface{})
- func OnErrPanicf(err error, format string, v ...interface{})
- func OnErrWarnf(err error, format string, v ...interface{})
- func Panicf(format string, v ...interface{})
- func SetFlags(flag int)
- func SetOutput(w io.Writer)
- func Warningf(format string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( // DebugLevel indicates if we should log at the debug level DebugLevel = true // LoggerInfo is the slog Info logger LoggerInfo = log.New(os.Stderr, "INFO ", defaultFlags) // LoggerWarning is the slog Warning logger LoggerWarning = log.New(os.Stderr, "WARNING ", defaultFlags) // LoggerError is the slog Error logger LoggerError = log.New(os.Stderr, "ERROR ", defaultFlags) // LoggerDebug is the slog Debug logger LoggerDebug = log.New(os.Stderr, "DEBUG ", defaultFlags) )
Functions ¶
func Debugf ¶ added in v1.3.0
func Debugf(format string, v ...interface{})
Debugf will log with a DEBUG prefix if DebugLevel is set
func Errorf ¶ added in v1.3.0
func Errorf(format string, v ...interface{})
Errorf will log with a ERROR prefix
func Fatalf ¶ added in v1.3.0
func Fatalf(format string, v ...interface{})
Fatalf will log with a ERROR prefix followed by exit(1)
func Infof ¶ added in v1.3.0
func Infof(format string, v ...interface{})
Infof formats logs with an INFO prefix
func Logf ¶ added in v1.3.0
func Logf(format string, v ...interface{})
Logf formats logs directly to the main logger
func OnErrFatalf ¶ added in v1.3.0
OnErrFatalf if error provided, will log out details of an error and exit
func OnErrPanicf ¶ added in v1.3.0
OnErrPanicf if error provided, will log out details of an error and exit
func OnErrWarnf ¶ added in v1.3.0
OnErrWarnf if error provided, will provide a warning if an error is provided
func Panicf ¶ added in v1.3.0
func Panicf(format string, v ...interface{})
Panicf will log with a ERROR prefix followed by panic()
func SetFlags ¶
func SetFlags(flag int)
SetFlags allows changing the logger flags using flags found in `log`
Types ¶
This section is empty.