diff --git a/logs/input/file/scanner.go b/logs/input/file/scanner.go index 263bb6f..ead47ff 100644 --- a/logs/input/file/scanner.go +++ b/logs/input/file/scanner.go @@ -14,6 +14,7 @@ import ( "sync/atomic" "time" + coreconfig "flashcat.cloud/categraf/config" logsconfig "flashcat.cloud/categraf/config/logs" "flashcat.cloud/categraf/logs/auditor" "flashcat.cloud/categraf/logs/message" @@ -260,7 +261,9 @@ func (s *Scanner) startNewTailer(file *File, m logsconfig.TailingMode) bool { log.Println("W! Could not recover offset for file with path", file.Path, err) } - // log.Printf("Starting a new tailer for: %s (offset: %d, whence: %d) for tailer key %s\n", file.Path, offset, whence, file.GetScanKey()) + if coreconfig.Config.DebugMode { + log.Printf("Starting a new tailer for: %s (offset: %d, whence: %d) for tailer key %s\n", file.Path, offset, whence, file.GetScanKey()) + } err = tailer.Start(offset, whence) if err != nil { log.Println(err) diff --git a/logs/input/file/tailer_nix.go b/logs/input/file/tailer_nix.go index 5cdc70a..b478fd4 100644 --- a/logs/input/file/tailer_nix.go +++ b/logs/input/file/tailer_nix.go @@ -11,8 +11,10 @@ package file import ( "fmt" "io" + "log" "path/filepath" + coreconfig "flashcat.cloud/categraf/config" "flashcat.cloud/categraf/logs/decoder" ) @@ -27,7 +29,9 @@ func (t *Tailer) setup(offset int64, whence int) error { // adds metadata to enable users to filter logs by filename t.tags = t.buildTailerTags() - // log.Println("I! Opening", t.file.Path, "for tailer key", t.file.GetScanKey()) + if coreconfig.Config.DebugMode { + log.Println("I! Opening", t.file.Path, "for tailer key", t.file.GetScanKey()) + } f, err := openFile(fullpath) if err != nil { return err