Package Logger:

- Add option to define the buffer size for logger file
- Rework Hashicorp wrapper to not use a standalone pointer of logger and prefer a function to retrieve the logger
- reword some panic recovery message
This commit is contained in:
Nicolas JUHEL
2023-12-14 13:49:14 +01:00
parent eb9f94e916
commit 782f59d0aa
7 changed files with 239 additions and 55 deletions

View File

@@ -36,6 +36,7 @@ import (
logcfg "github.com/nabbar/golib/logger/config"
loglvl "github.com/nabbar/golib/logger/level"
logtps "github.com/nabbar/golib/logger/types"
libsiz "github.com/nabbar/golib/size"
"github.com/sirupsen/logrus"
)
@@ -78,6 +79,7 @@ func New(opt logcfg.OptionsFile, format logrus.Formatter) (HookFile, error) {
n := &hkf{
s: new(atomic.Value),
d: new(atomic.Value),
b: new(atomic.Int64),
o: ohkf{
format: format,
flags: flags,
@@ -93,6 +95,12 @@ func New(opt logcfg.OptionsFile, format logrus.Formatter) (HookFile, error) {
},
}
if opt.FileBufferSize <= libsiz.SizeKilo {
n.b.Store(opt.FileBufferSize.Int64())
} else {
n.b.Store(sizeBuffer)
}
if opt.CreatePath {
if e := libiot.PathCheckCreate(true, opt.Filepath, opt.FileMode, opt.PathMode); e != nil {
return nil, e