diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-14 12:35:10 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-12-14 15:41:39 +0100 |
| commit | e1cc6375180bf75ae8a7831fc72c27c03191ce61 (patch) | |
| tree | 34f98448c2013a38557091a87316d4247b3034ad | |
| parent | 898881f89cf5b2bc459584394a72f939467089a2 (diff) | |
Log: Change Inherit to take format arguments
| -rw-r--r-- | internal/log/log.go | 14 |
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...) } } |
