- Notifications
You must be signed in to change notification settings - Fork29
Small command-line JSON Log viewer
License
brocode/fblog
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A small tool to view json log files.
fblog -a message -a"status > a" sample_nested.json.log
If your query docker or kubectl for multiple pods it will prefix the loglines:PODNAME | {"message": "test"}
.fblog
can parse this and addit to the message. Just use-p
.
To filter log messages it is possible to use lua. If you are unsurewhich variables are available you can use--print-lua
to see the codegenerated by fblog.
fblog -f'level ~= "info"'# will print all message where the level is not infofblog -f'process == "play"'# will print all message where the process is playfblog -f'string.find(fu, "bow.*") ~= nil'# will print all messages where fu starts with bowfblog -f'process == "play"'# will print all message where the process is playfblog -f'process == "rust" and fu == "bower"'fblog --no-implicit-filter-return-statement -f'if 3 > 2 then return true else return false end'# not valid lua identifiers like log.level gets converted to log_level.# Every character that is not _ or a letter will be converted to _fblog -d -f'log_level == "WARN"' sample_elastic.log# nested fields are converted to lua recordsfblog -d -f'status.a == 100' sample_nested.json.log# array fields are converted to lua tables (index starts with 1)fblog -d -f'status.d[2] == "a"' sample_nested.json.log
fblog
tries to detect the message, severity and timestamp of a logentry. This behavior can be customized. See--help
for moreinformation.
You can customize fblog messages: Format output:
fblog -p --main-line-format"{{#if short_message}}{{ red short_message }}{{/if}}" sample.json.log
The following sanitized variables are provided by fblog:
- fblog_timestamp
- fblog_level
- fblog_message
- fblog_prefix
For the default formatting see--help
Nested values are registered as objects. So you can usenested.value
to access nested values.
handlebar helpers:
- bold
- yellow
- red
- blue
- purple
- cyan
- green
- color_rgb 0 0 0
- uppercase
- level_style
- fixed_size 10
- min_size 10
fblog
disables color output if theNO_COLOR
environment variable ispresent.
Placeholders in the message (fblog_message
) can be substituted withtheir corresponding values in a context object or array. To enablesubstitutions, pass the-s
flag or either set context key(-c context
) or placeholder format (-F {key}
).
Note that the placeholder format should be written like<PREFIX>key<SUFFIX>
, where it would match a placeholder with the keykey
.
Given the following log (referred to asexample.log
):
{"message":"Found #{count} new items.","extra_data": {"count":556},"level":"info"}
Running with the following arguments:
fblog -c extra_data -F'#{key}' example.log
Result:
cargo install fblog
Available in package managers:AUR,brew
fblog
does not support native log tailing but this is easilyachievable.
tail -f file| fblog
Or with kubernetes tooling for example
kubectl logs -f ...| fblog
In general you can pipe any endless stream to fblog.
fblog --generate-completions<shell>
fblog
reads its configuration from a file calledfblog.toml
, which is located
Linux:$XDG_CONFIG_HOME
or$HOME/.config
Windows:{FOLDERID_RoamingAppData}
macOS:$HOME/Library/Application Support
If the file does not exist or is emptythis is the default config.
These levels are colorized by fblog:
tracedebuginfowarnerrorfatal
You can map additional level values (used for output and color):
[level_map]10 ="trace"20 ="debug"30 ="info"40 ="warn"50 ="error"60 ="fatal"# these values for example are used by https://www.npmjs.com/package/bunyan#levels
In the file~/.config/k9s/plugins.yaml
add this:
plugins:fblog-pod:shortCut:Shift-Lconfirm:falsedescription:"fblog"scopes: -podscommand:shbackground:falseargs: --c -"kubectl logs --follow -n $NAMESPACE $NAME | fblog"fblog-container:shortCut:Shift-Lconfirm:falsedescription:"fblog"scopes: -containerscommand:shbackground:falseargs: --c -"kubectl logs --follow -n $NAMESPACE $POD -c $NAME | fblog"fblog-pod-all:shortCut:Shift-Kconfirm:falsedescription:"fblog -d"scopes: -podscommand:shbackground:falseargs: --c -"kubectl logs --follow -n $NAMESPACE $NAME | fblog -d"fblog-container-all:shortCut:Shift-Kconfirm:falsedescription:"fblog -d"scopes: -containerscommand:shbackground:falseargs: --c -"kubectl logs --follow -n $NAMESPACE $POD -c $NAME | fblog -d"
About
Small command-line JSON Log viewer
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors12
Uh oh!
There was an error while loading.Please reload this page.