浏览代码

Fix log destination in one-shot mode (#2084)

mmetc 2 年之前
父节点
当前提交
a6bb2cf5e1
共有 2 个文件被更改,包括 6 次插入2 次删除
  1. 1 1
      .github/buildkit.toml
  2. 5 1
      cmd/crowdsec/main.go

+ 1 - 1
.github/buildkit.toml

@@ -1,2 +1,2 @@
 [worker.oci]
-  max-parallelism = 2
+#  max-parallelism = 2

+ 5 - 1
cmd/crowdsec/main.go

@@ -211,6 +211,11 @@ func LoadConfig(cConfig *csconfig.Config) error {
 		return err
 	}
 
+	if flags.SingleFileType != "" && flags.OneShotDSN != "" {
+		// if we're in time-machine mode, we don't want to log to file
+		cConfig.Common.LogMedia = "stdout"
+	}
+
 	// Configure logging
 	if err := types.SetDefaultLoggerConfig(cConfig.Common.LogMedia,
 		cConfig.Common.LogDir, *cConfig.Common.LogLevel,
@@ -264,7 +269,6 @@ func LoadConfig(cConfig *csconfig.Config) error {
 		if flags.DisableAPI {
 			cConfig.Common.Daemonize = false
 		}
-		cConfig.Common.LogMedia = "stdout"
 		log.Infof("single file mode : log_media=%s daemonize=%t", cConfig.Common.LogMedia, cConfig.Common.Daemonize)
 	}