Thibault bui Koechlin 5 年之前
父節點
當前提交
c62e5d5aec
共有 3 個文件被更改,包括 7 次插入8 次删除
  1. 1 1
      pkg/cwplugin/backend.go
  2. 4 4
      pkg/sqlite/commit.go
  3. 2 3
      pkg/sqlite/sqlite.go

+ 1 - 1
pkg/cwplugin/backend.go

@@ -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
 
 
 	}
 	}

+ 4 - 4
pkg/sqlite/commit.go

@@ -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 {

+ 2 - 3
pkg/sqlite/sqlite.go

@@ -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
-	//c.maxEventRetention = 100
+	//TBD : we shouldn't start auto-commit if we are in cli mode ?
 	c.PusherTomb.Go(func() error {
 	c.PusherTomb.Go(func() error {
 		c.AutoCommit()
 		c.AutoCommit()
 		return nil
 		return nil