mirror of
https://github.com/nabbar/golib.git
synced 2025-10-04 23:42:46 +08:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user