This commit is contained in:
Thibault bui Koechlin 2020-06-26 18:06:29 +02:00
parent 625e908894
commit c62e5d5aec
3 changed files with 7 additions and 8 deletions

View file

@ -119,7 +119,7 @@ func NewBackendPlugin(outputConfig map[string]string) (*BackendManager, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("plugin '%s' init error : %s", newPlugin.Name, err) return nil, fmt.Errorf("plugin '%s' init error : %s", newPlugin.Name, err)
} }
log.Infof("backend plugin '%s' loaded", newPlugin.Name) log.Debugf("backend plugin '%s' loaded", newPlugin.Name)
backendManager.backendPlugins[newPlugin.Name] = newPlugin backendManager.backendPlugins[newPlugin.Name] = newPlugin
} }

View file

@ -55,7 +55,7 @@ func (c *Context) CleanUpRecordsByAge() error {
//no events elligible //no events elligible
if len(sos) == 0 || ret.RowsAffected == 0 { if len(sos) == 0 || ret.RowsAffected == 0 {
log.Infof("no event older than %s", c.maxDurationRetention.String()) log.Debugf("no event older than %s", c.maxDurationRetention.String())
return nil return nil
} }
//let's do it in a single transaction //let's do it in a single transaction
@ -91,7 +91,7 @@ func (c *Context) CleanUpRecordsByCount() error {
return errors.Wrap(ret.Error, "failed to get bans count") return errors.Wrap(ret.Error, "failed to get bans count")
} }
if count < c.maxEventRetention { if count < c.maxEventRetention {
log.Infof("%d < %d, don't cleanup", count, c.maxEventRetention) log.Debugf("%d < %d, don't cleanup", count, c.maxEventRetention)
return nil return nil
} }
@ -130,12 +130,12 @@ func (c *Context) CleanUpRecordsByCount() error {
} }
func (c *Context) AutoCommit() { func (c *Context) AutoCommit() {
log.Warningf("starting autocommit") log.Infof("starting autocommit")
ticker := time.NewTicker(200 * time.Millisecond) ticker := time.NewTicker(200 * time.Millisecond)
cleanUpTicker := time.NewTicker(1 * time.Minute) cleanUpTicker := time.NewTicker(1 * time.Minute)
expireTicker := time.NewTicker(1 * time.Second) expireTicker := time.NewTicker(1 * time.Second)
if !c.flush { if !c.flush {
log.Infof("flush is disabled") log.Debugf("flush is disabled")
} }
for { for {
select { select {

View file

@ -52,7 +52,7 @@ func NewSQLite(cfg map[string]string) (*Context, error) {
if cfg["db_path"] == "" { if cfg["db_path"] == "" {
return nil, fmt.Errorf("please specify a 'db_path' to SQLite db in the configuration") return nil, fmt.Errorf("please specify a 'db_path' to SQLite db in the configuration")
} }
log.Warningf("Starting SQLite backend, path:%s", cfg["db_path"]) log.Infof("Starting SQLite backend, path:%s", cfg["db_path"])
c.Db, err = gorm.Open("sqlite3", cfg["db_path"]+"?_busy_timeout=1000") c.Db, err = gorm.Open("sqlite3", cfg["db_path"]+"?_busy_timeout=1000")
if err != nil { if err != nil {
@ -84,8 +84,7 @@ func NewSQLite(cfg map[string]string) (*Context, error) {
if c.tx == nil { if c.tx == nil {
return nil, fmt.Errorf("failed to begin sqlite transac : %s", err) return nil, fmt.Errorf("failed to begin sqlite transac : %s", err)
} }
//random attempt //TBD : we shouldn't start auto-commit if we are in cli mode ?
//c.maxEventRetention = 100
c.PusherTomb.Go(func() error { c.PusherTomb.Go(func() error {
c.AutoCommit() c.AutoCommit()
return nil return nil