Add multiple log monitoring support.

This commit is contained in:
Random-Liu
2017-02-15 13:15:18 -08:00
parent 92e67b8615
commit 6170b0c87f
6 changed files with 57 additions and 15 deletions
@@ -20,6 +20,7 @@ package journald
import (
"fmt"
"os"
"strings"
"time"
@@ -134,6 +135,11 @@ func getJournal(cfg types.WatcherConfig) (*sdjournal.Journal, error) {
if err != nil {
return nil, fmt.Errorf("failed to parse lookback duration %q: %v", cfg.Lookback, err)
}
// If the path doesn't present, NewJournalFromDir will create it instead of
// returning error. So check the path existence ourselves.
if _, err := os.Stat(path); err != nil {
return nil, fmt.Errorf("failed to stat the log path %q: %v", path, err)
}
// Get journal client from the log path.
journal, err := sdjournal.NewJournalFromDir(path)
if err != nil {