diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-01-31 13:42:29 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-01-31 14:30:39 +0000 |
commit | 1cf70cdb76ce8f66a8006963ab3dc1033fc342ec (patch) | |
tree | 3f23c12250277db86531ee09b88fea3fdddfd30c /client/go/script-utils/logfmt/options.go | |
parent | 3e54969fc961ee51c93404a37d559ab7ea2f9fe6 (diff) |
move vespa-logfmt command
Diffstat (limited to 'client/go/script-utils/logfmt/options.go')
-rw-r--r-- | client/go/script-utils/logfmt/options.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/client/go/script-utils/logfmt/options.go b/client/go/script-utils/logfmt/options.go new file mode 100644 index 00000000000..864868d4ce5 --- /dev/null +++ b/client/go/script-utils/logfmt/options.go @@ -0,0 +1,48 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa logfmt command +// Author: arnej + +package logfmt + +import ( + "fmt" + "os" +) + +// options designed for compatibility with perl version of vespa-logfmt + +type Options struct { + ShowFields flagValueForShow + ShowLevels flagValueForLevel + OnlyHostname string + OnlyPid string + OnlyService string + OnlyInternal bool + FollowTail bool + DequoteNewlines bool + TruncateService bool + TruncateComponent bool + ComponentFilter regexFlag + MessageFilter regexFlag + Format OutputFormat +} + +func NewOptions() (ret Options) { + ret.ShowLevels.levels = defaultLevelFlags() + ret.ShowFields.shown = defaultShowFlags() + return +} + +func (o *Options) showField(field string) bool { + return o.ShowFields.shown[field] +} + +func (o *Options) showLevel(level string) bool { + rv, ok := o.ShowLevels.levels[level] + if !ok { + o.ShowLevels.levels[level] = true + fmt.Fprintf(os.Stderr, "Warnings: unknown level '%s' in input\n", level) + return true + } + return rv +} |