Takes JSON-formatted logrus log messages as input and prints them back out in a more human readable format.
go build -o plr ./...Put the plr executable somewhere on your PATH.
kubectl logs <pod> | plrUsage together with pod-id
Pod-id is a small utility to get the pod id from a partial pod name.
It lets you look up pods by a partial name, like this:
kubectl logs $(podid my-app)This shell alias is useful for combining podid and plr:
alias klogs='kubectl logs $(podid $1) | plr'To also be able to pass arguments to plr, replace the alias with this function:
klogs () {
local pod_id
pod_id=$(podid "$1")
shift
kubectl logs "$pod_id" | plr "$@"
}
# Usage examples:
klogs my-app # prints the logs from the pod where the name contains "my-app".
klogs my-app --field trace.id # pretty-logrus arguments work as expected.Note: The
klogsfunction does not forward arguments to pod-id. If you need to pass arguments to pod-id, you can use the full command:kubectl logs $(podid my-app <args here>) | plr.
--multi-line | -M: Print output on multiple lines with log message and level first and then each data field on separate lines.--no-data: Don't show any logged data fields.--level <level> | -L: Only show log messages matching this level. Values (logrus levels):trace|debug|info|warning|error|fatal|panic--min-level <level>: Only show log messages at this log level or higher. Severity levels:trace=1, debug=2, info=3, warning=4, error=5, fatal=6, panic=7--max-level <level>: Only show log messages at this log level or lower. Severity levels:trace=1, debug=2, info=3, warning=4, error=5, fatal=6, panic=7--fields <field>(,<field>) | -F: Only show specific data field(s). Several field names can be separated by comma. Field name can have leading and/or trailing wildcard*.--except <field>(,<field>) | -E: Don't show this particular field or fields separated by comma. Field name can have leading and/or trailing wildcard*.--trunc <field>=<num chars or substr>: Truncate the content of this field by an index or substring.--where <field>=<value> | -W: Only show log messages where the value occurs.--highlight-key <field> | -K: Highlight the key of the field in the output. Field name can have leading and/or trailing wildcard*. By default, this is displayed in bold red text. Styles can be overridden in the configuration file.--highlight-value <field value> | -V: Highlight the value of the field in the output. Field value can have leading and/or trailing wildcard*. By default, this is displayed in bold red text. Styles can be overridden in the configuration file.--all-fields: Show all data fields regardless of--exceptflag or fields being excluded viaExcludedFieldsin the config file.
--trunc message=50: Print the first 50 characters in the message field--trunc message="\n": Print everything up until the first line break in the message field--trunc message="\t": Print everything up until the first tab character in the message field--trunc message=mytext: Print everything up until the first occurrence of the phrase 'mytext' in the message field.--trunc message="stop it": Print everything up until the first occurrence of the phrase 'stop it' in the message field.--trunc message=" ": Print everything up until the first empty space in the message field.
--where <field>=<value>: Only show log messages where the specific field has the given value--where <field>=<value>,<field>=<value>: Specify multiple conditions separated by comma--where <value>: Only show log messages where the value occurs in any data field or the message field. Value can be a partial phrase or text.
Several flags support the wildcard * in their values to match several things at once:
--fields--except--highlight-key--highlight-value
Usage:
- Leading:
--arg "*foo"will match phrases ending with "foo" (case sensitive). - Trailing:
--arg "foo*"will match phrases starting with "foo" (case sensitive). - Both:
--arg "*foo*"will match phrases containing "foo" (case sensitive).
Gotcha 1: You might need to quote the string:
--arg labels.* might give the output zsh: no matches found: labels.* whereas
--arg "labels.*" will filter on fields beginning with the phrase "labels.".
Gotcha 2: it's case sensitive. For example when searching for values with --highlight-value like --highlight-value "my-service*", "my-service" will be matched as-is.
default-config: Prints the default configuration file to stdoutinit: Creates a config file at the locationPRETTY_LOGRUS_HOMEis pointing to. It is required to set this environment variable to run this command.
See the configuration spec for how to set up the configuration file.
π οΈ - Enhancements, improvements
β¨ - New features, additions
π - Bug fixes
π₯ - Breaking changes
βοΈ - Remove features, deletions
π 2025-12-19
- π Fix a bug where args were treated like commands.
π 2025-12-19
- π οΈ Move LogLevelToSeverity map to config file. See CONFIG_FILE_SPEC for more information. This can be used to control how the
--level,--min-leveland--max-levelflags work.
π 2025-12-19
- β¨ Added support for config file via environment variable
PRETTY_LOGRUS_HOME. See CONFIG_FILE_SPEC for more information. - β¨ Added support for overriding colors and styling via config file. See CONFIG_FILE_SPEC for more information. This can be useful to highlight certain fields like you want or adapt the color scheme to your terminal.
- β¨ Added support for excluding fields from log entries via config file, if there are fields that are more noise and you don't want to see them in the output for most of the time. This basically does the same thing as the
--exceptflag. - β¨ Added
--all-fieldsflag to show all fields, including excluded ones from config file or the ones from the--exceptarg. - β¨ Addad
default-configcommand to print the default configuration file to stdout:plr default-config. - β¨ Added
initcommand to create a config file at the locationPRETTY_LOGRUS_HOMEis pointing to. It is required to set this environment variable to run this command:PRETTY_LOGRUS_HOME=~/.config/plr plr init
π 2025-04-01
- β¨ Added
--min-leveland--max-levelarguments to specify when you want to show log messages with at least or at most a certain log level severity. The log levels are ordered like this:trace=1, debug=2, info=3, warning=4, error=5, fatal=6, panic=7. Use the log level name to specify the argument, like:--min-level warning, this would only show log messages with the levelswarning,error,fatalandpanic.
π 2024-05-28
- π₯ Removed the
--fieldflag. Use--fieldsinstead. There is no difference in usage, except--fieldscan do more than--fieldcould and as such it was redundant having two really similar args. The-Fshorthand alias has also been moved to--fields. - π οΈ Added default colors for all logrus log levels. The colors can be overridden in the configuration file.
- π οΈ Added
-Eshorthand alias for the--exceptarg.
π 2024-05-26
- π use
path.Join()when reading config.json to avoid OS-related file path issues. - π misc refactoring and cleanup.
π 2024-05-26
- π οΈ Add shorthand aliases to some CLI arguments.
- π Fix various style-related bugs.
π 2024-05-24
- β¨ Added a configuration file to customize various aspects of the app, like the text styles. See the configuration file spec for more information.
- β¨ Added
--highlight-keyand--highlight-valueflags to highlight specific fields or values in the output.
βοΈ Highlighting the key
trace.id (--highlight-key trace.id).
βοΈ Highlighting all values containing
abc (--highlight-value "*abc*").
π 2024-05-24
- π οΈ Fields are sorted alphabetically.
- π οΈ Include (
--field,--fields) and exclude (--except) flags can now take a wildcard*to match several fields at once.
π 2024-04-08
β¨ Added --where flag to filter log messages based on field values. Example: --where trace.id=1234. See usage examples above for more variations.
π 2023-03-13
- π οΈ Support tailing like
kubectl logs -f | plr
π 2022-10-24
- π οΈ A field named
labelswill be treated as a map of other sub-fields and each sub-field under labels will be printed aslabels.<subfield>=[<value>]. Example:
Before
labels=[map[string]struct{ foo: "bar", abc: "def" }]
After
labels.foo=[bar] labels.abc=[def]
π 2022-10-06
- π If a log line cannot be parsed (i.e. if it's not a line with JSON on the expected logrus format), it will be printed as-is instead of being ignored by the error handler.
π 2022-10-04
- π οΈ Truncate flag now supports substrings, newline and tab characters in addition to a character index.
π 2022-10-04
- β¨ Added
--truncflag to limit the output length of a certain field. The value of the given field name will be cut off at the given character index. Only one field can be truncated at a time. Example:--trunc service.name=10. - π Fixed a bug where long lines would be skipped entirely and the line would be lost without any warning or information.
No changelog at this time