Browse Source

added overrideable hostname for log tails

Tobias Begalke 6 years ago
parent
commit
adffd1653d
1 changed files with 4 additions and 0 deletions
  1. 4 0
      main.go

+ 4 - 0
main.go

@@ -50,6 +50,7 @@ var (
 	apacheLog             = flag.String("apache-log", "", "Parse an Apache Log file")
 	nginxLog              = flag.String("nginx-log", "", "Nginx log file to tail")
 	nginxFormat           = flag.String("nginx-format", "", "The nginx log file format")
+	hostName              = flag.String("hostname", "", "Override the captured hostname with this one")
 	configFile            = flag.String("config", "", "The location of the TOML config file")
 
 	beQuiet   = flag.Bool("quiet", true, "Be quiet")
@@ -92,6 +93,7 @@ type Config struct {
 	ApacheLog             string
 	NginxLog              string
 	NginxLogFormat        string
+	HostName              string
 }
 
 type duration struct {
@@ -120,6 +122,7 @@ func (c Config) print() {
 	fmt.Printf("Apache Log:            %s\n", c.ApacheLog)
 	fmt.Printf("Nginx Log:             %s\n", c.NginxLog)
 	fmt.Printf("Nginx Log Format:      %s\n", c.NginxLogFormat)
+	fmt.Printf("HostName:             %s\n", c.HostName)
 	fmt.Printf("UseXForwardedAsSource: %t\n", c.UseXForwardedAsSource)
 	fmt.Printf("Protocol:              %s\n", c.Protocol)
 	fmt.Printf("Quiet:                 %t\n", c.Quiet)
@@ -757,6 +760,7 @@ func loadConfig() {
 	config.ApacheLog = *apacheLog
 	config.NginxLog = *nginxLog
 	config.NginxLogFormat = *nginxFormat
+	config.HostName = *hostName
 	config.Quiet = *beQuiet
 	config.Trace = *trace