job manager, jobm pkg

This commit is contained in:
Sebastian Frank
2019-03-25 10:16:33 +01:00
parent a17926f54b
commit 740fb94556
7 changed files with 245 additions and 178 deletions

View File

@@ -13,7 +13,7 @@ var logBackendLeveled logging.LeveledBackend
// SetLogLevel sets log level for global logger (debug, info, notice, warning, error)
func SetLogLevel(level string) {
logBackendLevel := logging.NOTICE
logBackendLevel := logging.INFO
switch level {
case "debug":
logBackendLevel = logging.DEBUG
@@ -58,3 +58,67 @@ func init() {
spew.Config.DisablePointerMethods = true
configureLogger()
}
// D is shorthand for Debugf
func D(format string, args ...interface{}) {
Log.Debugf(format, args...)
}
// I is shorthand for Infof
func I(format string, args ...interface{}) {
Log.Infof(format, args...)
}
// N is shorthand for Noticef
func N(format string, args ...interface{}) {
Log.Noticef(format, args...)
}
// W is shorthand for Warningf
func W(format string, args ...interface{}) {
Log.Warningf(format, args...)
}
// E is shorthand for Errorf
func E(format string, args ...interface{}) {
Log.Errorf(format, args...)
}
// P is shorthand for Panicf
func P(format string, args ...interface{}) {
Log.Panicf(format, args...)
}
// Eerr is shorthand for
// if err != nil {
// Log.Errorf(...)
// }
func Eerr(err error, format string, args ...interface{}) {
if err != nil {
args = append(args, err)
Log.Errorf(format+"\nError: %s", args...)
}
}
// Eexit is shorthand for
// if err != nil {
// Log.Errorf(...)
// os.Exit(1)
// }
func Eexit(err error, format string, args ...interface{}) {
Eerr(err, format, args...)
if err != nil {
os.Exit(1)
}
}
// Perr is shorthand for
// if err != nil {
// Log.Panicf(...)
// }
func Perr(err error, format string, args ...interface{}) {
if err != nil {
args = append(args, err)
Log.Panicf(format+"\nError: %s", args...)
}
}