summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-14 12:35:10 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-14 15:41:39 +0100
commite1cc6375180bf75ae8a7831fc72c27c03191ce61 (patch)
tree34f98448c2013a38557091a87316d4247b3034ad /internal
parent898881f89cf5b2bc459584394a72f939467089a2 (diff)
Log: Change Inherit to take format arguments
Diffstat (limited to 'internal')
-rw-r--r--internal/log/log.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/log/log.go b/internal/log/log.go
index 101c112..be4730f 100644
--- a/internal/log/log.go
+++ b/internal/log/log.go
@@ -112,20 +112,22 @@ func (logger *FileLogger) Init(lvl Level, dir string) error {
return nil
}
-// Inherit logs an error with a label using the error level of the error.
-func (logger *FileLogger) Inherit(err error) {
+// Inheritf logs an error with a message and params using the error level verbosity of the error.
+// The message is always prefixed with the error.
+func (logger *FileLogger) Inheritf(err error, msg string, params...interface{}) {
if err == nil {
return
}
+ s := err.Error() + msg
switch GetErrorLevel(err) {
case ErrInfo:
- logger.Infof(err.Error())
+ logger.Infof(s, params...)
case ErrWarning:
- logger.Warningf(err.Error())
+ logger.Warningf(s, params...)
case ErrOther:
- logger.Errorf(err.Error())
+ logger.Errorf(s, params...)
case ErrFatal:
- logger.Fatalf(err.Error())
+ logger.Fatalf(s, params...)
}
}