Skip to content

Commit

Permalink
adds validation warning to config. exit with error when supplied no f…
Browse files Browse the repository at this point in the history
…iles to watch
  • Loading branch information
featalion committed Jun 18, 2015
1 parent eb9b7b7 commit 0835aa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ type ConfigFile struct {
ExcludePatterns *RegexCollection `yaml:"exclude_patterns"`
}

func (cf ConfigFile) printValidationWarnings() {
if len(cf.Files) == 0 {
log.Warningf("Configuration file contains no files to watch")
}
// Warn, that port is not set, only if host is specified
if cf.Destination.Host != "" && cf.Destination.Port == 0 {
log.Warningf("Destination port is not specified in configuration file")
}
}

type ConfigManager struct {
Config ConfigFile
FlagFiles []string
Expand Down Expand Up @@ -199,6 +209,8 @@ func (cm *ConfigManager) loadConfigFile() error {
if err != nil {
return fmt.Errorf("Could not parse the config file: %s", err)
}
cm.Config.printValidationWarnings()

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions remote_syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func tailOne(file string, excludePatterns []*regexp.Regexp, logger *syslog.Logge
// Tails files speficied in the globs and re-evaluates the globs
// at the specified interval
func tailFiles(globs []string, excludedFiles []*regexp.Regexp, excludePatterns []*regexp.Regexp, interval RefreshInterval, logger *syslog.Logger, severity syslog.Priority, facility syslog.Priority, poll bool) {
if len(globs) == 0 {
log.Criticalf("Supplied no files to watch")
os.Exit(1)
}

wr := NewWorkerRegistry()
log.Debugf("Evaluating globs every %s", interval.Duration)
logMissingFiles := true
Expand Down

0 comments on commit 0835aa8

Please sign in to comment.