Commit d2d2becb authored by ale's avatar ale
Browse files

Set --url also via env var ELASTICSEARCH_URL

parent 60758216
......@@ -23,7 +23,7 @@ import (
)
var (
elasticURL = flag.String("url", "http://127.0.0.1:9200", "Elasticsearch URL")
elasticURL = flag.String("url", getenv("ELASTICSEARCH_URL", "http://127.0.0.1:9200"), "Elasticsearch URL")
fromDate = flag.String("from", "-1h", "start `date`")
toDate = flag.String("to", "", "end `date` (default now, otherwise relative to --from)")
doDumpQuery = flag.Bool("dump-query", false, "don't do anything, just print the ES query as JSON")
......@@ -33,6 +33,13 @@ var (
isoTimestamps = flag.Bool("iso", false, "dump ISO timestamps")
)
func getenv(k, dflt string) string {
if s := os.Getenv(k); s != "" {
return s
}
return dflt
}
func usage() {
// nolint: errcheck
fmt.Fprintf(os.Stderr, `Usage: logcat [<options>] <query>...
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment