36 releases (stable)

4.2.0 Nov 11, 2022
4.0.0 Feb 16, 2022
3.2.0 Feb 8, 2022
3.1.2 Dec 10, 2021
0.3.3 Jul 19, 2017

#34 in Command line utilities

Download history 87/week @ 2022-11-27 48/week @ 2022-12-04 58/week @ 2022-12-11 29/week @ 2022-12-18 24/week @ 2022-12-25 55/week @ 2023-01-01 31/week @ 2023-01-08 47/week @ 2023-01-15 65/week @ 2023-01-22 94/week @ 2023-01-29 228/week @ 2023-02-05 122/week @ 2023-02-12 176/week @ 2023-02-19 62/week @ 2023-02-26 52/week @ 2023-03-05 42/week @ 2023-03-12

339 downloads per month

WTFPL license

185KB
850 lines

[[./logo/fblog_small.png]]

** Print specific fields

#+BEGIN_SRC shell-script fblog -a message -a "status > a" sample_nested.json.log #+END_SRC

** Filter To filter log messages it is possible to use lua. If you are unsure which variables are available you can use --print-lua to see the code generated by fblog.

#+BEGIN_SRC shell-script fblog -f 'level ~= "info"' # will print all message where the level is not info fblog -f 'process == "play"' # will print all message where the process is play fblog -f 'string.find(fu, "bow.*") ~= nil' # will print all messages where fu starts with bow fblog -f 'process == "play"' # will print all message where the process is play fblog -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 records

fblog -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 #+END_SRC

** Customize fblog tries to detect the message, severity and timestamp of a log entry. This behavior can be customized. See --help for more information.

You can customize fblog messages: Format output: #+BEGIN_SRC shell-script fblog -p --main-line-format "{{#if short_message}}{{ red short_message }}{{/if}}" sample.json.log #+END_SRC

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 use nested.value to access nested values.

handlebar helpers:

  • bold
  • yellow
  • red
  • blue
  • purple
  • green
  • color_rgb 0 0 0
  • uppercase
  • level_style
  • fixed_size 10

** NO_COLOR fblog disables color output if the NO_COLOR environment variable is present.

[[https://no-color.org/][no-color]]

** Installation #+BEGIN_SRC bash cargo install fblog #+END_SRC

Available in package managers: [[https://aur.archlinux.org/packages/fblog/][AUR]], [[https://formulae.brew.sh/formula/fblog][brew]]

** Log tailing fblog does not support native log tailing but this is easily achiveable.

#+BEGIN_SRC bash tail -f file | fblog #+END_SRC

Or with kubernetes tooling for example

#+BEGIN_SRC bash kubectl logs -f ... | fblog #+END_SRC

In general you can pipe any endless stream to fblog.

** Discord In the case you want to talk about new features or give us direct feedback, you can join the [[https://rawkode.chat/][Discord]] (Thanks [[https://github.com/rawkode][@rawkode]]) in the forum channel oss-projects / #fblog.

Dependencies

~8.5MB
~179K SLoC