add debug log

This commit is contained in:
kongfei 2022-06-02 21:29:09 +08:00
parent 1f85f3191b
commit 870a20a6dc
2 changed files with 9 additions and 2 deletions

View File

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

View File

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