-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
296 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,19 +57,25 @@ VERSION: | |
0.5.0 | ||
AUTHOR: | ||
Antoine Grondin - <[email protected]> | ||
Antoine Grondin - <[email protected]> | ||
COMMANDS: | ||
help, h Shows a list of commands or help for one command | ||
GLOBAL OPTIONS: | ||
--skip '--skip option --skip option' keys to skip when parsing a log entry | ||
--keep '--keep option --keep option' keys to keep when parsing a log entry | ||
--sort-longest sort by longest key after having sorted lexicographically | ||
--skip-unchanged skip keys that have the same value than the previous entry | ||
--truncate truncates values that are longer than --truncate-length | ||
--truncate-length '15' truncate values that are longer than this length | ||
--help, -h show help | ||
--version, -v print the version | ||
--skip value keys to skip when parsing a log entry | ||
--keep value keys to keep when parsing a log entry | ||
--sort-longest sort by longest key after having sorted lexicographically | ||
--skip-unchanged skip keys that have the same value than the previous entry | ||
--truncate truncates values that are longer than --truncate-length | ||
--truncate-length value truncate values that are longer than this length (default: 15) | ||
--light-bg use black as the base foreground color (for terminals with light backgrounds) | ||
--time-format value output time format, see https://golang.org/pkg/time/ for details (default: "Jan _2 15:04:05") | ||
--ignore-interrupts, -i ignore interrupts | ||
--message-fields value, -m value Custom JSON fields to search for the log message. (i.e. mssge, data.body.message) (default: "data.message") [$HUMANLOG_MESSAGE_FIELDS] | ||
--time-fields value, -t value Custom JSON fields to search for the log time. (i.e. logtime, data.body.datetime) [$HUMANLOG_TIME_FIELDS] | ||
--level-fields value, -l value Custom JSON fields to search for the log level. (i.e. somelevel, data.level) [$HUMANLOG_LEVEL_FIELDS] | ||
--help, -h show help | ||
--version, -v print the version | ||
``` | ||
[l2met]: https://github.com/ryandotsmith/l2met |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,14 +88,38 @@ func newApp() *cli.App { | |
Usage: "ignore interrupts", | ||
} | ||
|
||
messageFields := cli.StringSlice{} | ||
messageFieldsFlag := cli.StringSliceFlag{ | ||
Name: "message-fields, m", | ||
Usage: "Custom JSON fields to search for the log message. (i.e. mssge, data.body.message)", | ||
EnvVar: "HUMANLOG_MESSAGE_FIELDS", | ||
Value: &messageFields, | ||
} | ||
|
||
timeFields := cli.StringSlice{} | ||
timeFieldsFlag := cli.StringSliceFlag{ | ||
Name: "time-fields, t", | ||
Usage: "Custom JSON fields to search for the log time. (i.e. logtime, data.body.datetime)", | ||
EnvVar: "HUMANLOG_TIME_FIELDS", | ||
Value: &timeFields, | ||
} | ||
|
||
levelFields := cli.StringSlice{} | ||
levelFieldsFlag := cli.StringSliceFlag{ | ||
Name: "level-fields, l", | ||
Usage: "Custom JSON fields to search for the log level. (i.e. somelevel, data.level)", | ||
EnvVar: "HUMANLOG_LEVEL_FIELDS", | ||
Value: &levelFields, | ||
} | ||
|
||
app := cli.NewApp() | ||
app.Author = "Antoine Grondin" | ||
app.Email = "[email protected]" | ||
app.Name = "humanlog" | ||
app.Version = Version | ||
app.Usage = "reads structured logs from stdin, makes them pretty on stdout!" | ||
|
||
app.Flags = []cli.Flag{skipFlag, keepFlag, sortLongest, skipUnchanged, truncates, truncateLength, lightBg, timeFormat, ignoreInterrupts} | ||
app.Flags = []cli.Flag{skipFlag, keepFlag, sortLongest, skipUnchanged, truncates, truncateLength, lightBg, timeFormat, ignoreInterrupts, messageFieldsFlag, timeFieldsFlag, levelFieldsFlag} | ||
|
||
app.Action = func(c *cli.Context) error { | ||
|
||
|
@@ -116,6 +140,18 @@ func newApp() *cli.App { | |
opts.SetKeep(keep) | ||
} | ||
|
||
if c.IsSet(strings.Split(messageFieldsFlag.Name, ",")[0]) { | ||
opts.MessageFields = messageFields | ||
} | ||
|
||
if c.IsSet(strings.Split(timeFieldsFlag.Name, ",")[0]) { | ||
opts.TimeFields = timeFields | ||
} | ||
|
||
if c.IsSet(strings.Split(levelFieldsFlag.Name, ",")[0]) { | ||
opts.LevelFields = levelFields | ||
} | ||
|
||
if c.IsSet(strings.Split(ignoreInterrupts.Name, ",")[0]) { | ||
signal.Ignore(os.Interrupt) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.