Small command-line JSON Log viewer

Overview

./logo/fblog_small.png

fblog

https://img.shields.io/crates/v/fblog.svg https://travis-ci.org/brocode/fblog.svg?branch=master

A small tool to view json log files.

demo.png

Filter

To filter log messages it is possible to use lua

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
fblog -d -f '_G["log.level"] == "WARN"' sample_elastic.log

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:

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

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.

no-color

Installation

cargo install fblog

If you need a deb or rpm package have a look at fblog releases

If you’re lucky enough to be an arch linux user: AUR

Comments
  • RFE: Customizable core fields & layout

    RFE: Customizable core fields & layout

    I like the idea that for each log event fblog displays a main line and optional additional lines per field. However, succinctness is also a virtue. Three lines to display message + logger name + thread name is a significant waste of vertical space. Thus, I had like to be able to cram more info into the main line.

    jaslog, a similar project, includes logger and thread name, https://github.com/jbruggem/jaslog/blob/master/src/line_formats.rs#L76. It seems a reasonable decision, but I imagine that essential fields are context dependent and every user has its personal opinion about what to display in the main line.

    Would it make sense to:

    1. Add more fields to the main line
    2. Provide a configuration mechanism to decide what, and perhaps how, to display in the main line
    enhancement 
    opened by cykl 16
  • thread 'main' panicked at 'Expect to be able to write to out stream.'

    thread 'main' panicked at 'Expect to be able to write to out stream.'

    Sorry to bother you again. This happens when you pipe to less and then quit, like so (bash):

    > fblog -d huge-log.json | less -r
    # now press `:q` to quit less
    thread 'main' panicked at 'Expect to be able to write to out stream.: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', src/log.rs:100:7
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    

    I don't think that it's a problem, but it doesn't look nice.

    enhancement 
    opened by mgmgwi 10
  • [feat] Add -x option to exclude values

    [feat] Add -x option to exclude values

    Hey, this was useful for me so I opened this PR.

    -x (eXclude values) enabled --dump-all and remove specified values.

    I tested it locally and it works fine for me. Attaching a picture of the help. image

    opened by idanski 7
  • Print all fields of a nested json object

    Print all fields of a nested json object

    Hi, thank you for the useful tool! I have an issue with using the flag "--additional-value".

    I'm using fblog v3.0.2 built by myself using Cargo and source code.

    The output of execute $ fblog --help:

    fblog 3.0.2
    Brocode inc <[email protected]>
    json log viewer
    
    USAGE:
        fblog [FLAGS] [OPTIONS] [--] [INPUT]
    
    ...
    

    The problem is that the output does not contain the field I specified using the flag -a.

    I have the log message:

    {"time": "2021-11-08T13:55:45.924593+00:00", "level": "INFO", "caller": "/app/service/runner.py:58", "message": "Some message here", "process": "1", "thread": "MainThread", "function": "run", "line_no": "58", "module": "runner", "logger": "service.runner", "extra": {"a": 1}}
    

    I want to see a value of the key "extra", so i'm using fblog -a extra and it doesn't work. At the same time, if I use the command fblog -a module, the value of the key module is displayed correctly.

    Please help me figure out what I'm doing wrong, or confirm that this is a bug.

    enhancement 
    opened by MeisQuietude 5
  • messages are HTML escaped.

    messages are HTML escaped.

    Whe I use fblog - https://github.com/brocode/fblog/releases/download/v2.1.0/fblog.deb deb packaged version, It works greatly.

    But if I install with cargo install fblog, fblog print HTML escaped message.

    What's the difference?

    bug 
    opened by kwon37xi 5
  • pretty printed json seems to be an issue

    pretty printed json seems to be an issue

    I have a json file that I have to pre-process via jq after that run I end up in pretty printed (multiline) json. Feeding this into fblog causes some strange errors, example below:

    the json fed into fblog looks like (excerpt):

    {
      "@message": "[object Object]\nResponse Headers have already been sent",
      "@timestamp": "2021-05-05T11:00:42.627Z",
      "@fields": {
        "level": "error"
      }
    }
    {
      "@message": "[object Object]\nResponse Headers have already been sent",
      "@timestamp": "2021-05-05T11:01:13.650Z",
      "@fields": {
        "level": "error"
      }
    }
    

    This very json ends up like this:

    $ cat *json* | grep -v 'info' | grep -v 'debug' | jq '.log | fromjson ' | fblog
    
    ??? > {
    ??? >   "@message": "[object Object]\nResponse Headers have already been sent",
    ??? >   "@timestamp": "2021-05-05T11:00:42.627Z",
    ??? >   "@fields": {
    ??? >     "level": "error"
    ??? >   }
    ??? > }
    ??? > {
    ??? >   "@message": "[object Object]\nResponse Headers have already been sent",
    ??? >   "@timestamp": "2021-05-05T11:01:13.650Z",
    ??? >   "@fields": {
    ??? >     "level": "error"
    ??? >   }
    ??? > }
    

    besides the json keys not fitting the default of fblog (that can be fixed via -l | -m | -t) the whole multiline json topic seems to be the root cause.

    Does fblog expect single line json?

    opened by sassman 4
  • how filter fields separated by dashes

    how filter fields separated by dashes

    fblog -f 'method=="POST" and header.X-Customer-Id[1]=="123456"' -a body -a res_body req.log
    
    {
      "header":{
          "X-Tenant-Id": ["123456"]
      }
    }
    
    question 
    opened by gatspy 3
  • Support fields with other types than string.

    Support fields with other types than string.

    Sometime fblog does not parse number values(but sometime do).

    $ cat > x.json
    {"timestamp":"2020-09-17 07:11:54.936","@version":"1","message":"Done Good!. exitCode: 0","thread":"main","level":"INFO","caller_file_name":"MyApplication.java","caller_line_number":12345}
    
    $ cat x.json | .cargo/bin/fblog --main-line-format "{{fblog_timestamp}} {{level_style fblog_level}} [{{thread}}] ({{caller_file_name}}#{{caller_line_number}}) {{fblog_message}}"
    
    # there is no number 12345
    2020-09-17 07:11:54.936 INFO [main] (MyApplication.java#) Done Good!. exitCode: 0
    
    # the result I expected
    2020-09-17 07:11:54.936 INFO [main] (MyApplication.java#12345) Done Good!. exitCode: 0
    
    enhancement 
    opened by kwon37xi 3
  • Support for defaults from a config file

    Support for defaults from a config file

    First of all, thanks for this tool! I had an idea to make this for myself and was pleasantly surprised to find this already existed. :smile:

    I was wondering if it would be possible to add support to pull default configuration from a config file somewhere like ~/.config/fblog/fblog.toml, or somewhere similar, and maybe the ability to provide a config path on the command line? Our logs have a few fields that don't make sense to add as auto-detected fields but are still helpful to show when they come up. Including those by default from a config file would allow me to set up some defaults without needing to remember (or type) them every time.

    Thanks again!

    opened by aphistic 2
  • no-color compliant

    no-color compliant

    Would you consider implementing no-color?

    I could create a PR if you did.

    I ran into this while trying to pipe fblog output through less and getting something not as friendly

    ESC[1m2020-03-02T22:45:22ESC[0m ESC[1;31mERROR:ESC[0m Failed to send sms
    ESC[1;38;2;150;150;150m                     body:ESC[0m ID: 19169 Status: 1
    ESC[1;38;2;150;150;150m                     file:ESC[0m my/path/file.go:194
    ESC[1;38;2;150;150;150m                     func:ESC[0m other/path.monitorMsgID
    ESC[1;38;2;150;150;150m                    level:ESC[0m error
    ESC[1;38;2;150;150;150m                      msg:ESC[0m Failed to send sms
    ESC[1;38;2;150;150;150m                  request:ESC[0m http://localhost/query
    ESC[1;38;2;150;150;150m                     time:ESC[0m 2020-03-02T22:45:22Z
    ESC[1m2020-03-02T22:45:22ESC[0m ESC[1;31mERROR:ESC[0m Failed to send sms
    ESC[1;38;2;150;150;150m                    error:ESC[0m [{other/path/file.go:103: } {other/path/file.go:190: Failed to send sms}]
    ESC[1;38;2;150;150;150m                     file:ESC[0m my/path/file.go:106
    ESC[1;38;2;150;150;150m                     func:ESC[0m other/path.(*smsClient).Send
    ESC[1;38;2;150;150;150m                    level:ESC[0m error
    ESC[1;38;2;150;150;150m                      msg:ESC[0m Failed to send sms```
    enhancement 
    opened by MarAvFe 2
  • Support Elastic Common Schema fields

    Support Elastic Common Schema fields

    Last year elastic introduced elastic common schema. Basically, it is a syntactic and semantic convention for structured logging.

    This patch add support of ECS time (@timestamp) and level (logger.level) fields. Message is already fine.

    Other alternative fields were untested so I didn't add an unit test.

    $ cat /tmp/test4
    {"@timestamp":"2020-02-24T11:34:38.483Z", "log.level": "INFO", "message":"My message", "process.thread.name":"main","log.logger":"com.greencomnetworks.poc.Removeme","container.id":"thinkpad","service.type":"test","service.version":"N/A"}
    $ cargo run /tmp/test4 
        Finished dev [unoptimized + debuginfo] target(s) in 0.02s
         Running `target/debug/fblog /tmp/test4`
    2020-02-24T11:34:38  INFO: My message
    
    opened by cykl 2
  • Bump clap from 4.0.29 to 4.0.32

    Bump clap from 4.0.29 to 4.0.32

    Bumps clap from 4.0.29 to 4.0.32.

    Release notes

    Sourced from clap's releases.

    v4.0.32

    [4.0.32] - 2022-12-22

    Fixes

    • (parser) When overriding required(true), consider args that conflict with its group

    v4.0.31

    [4.0.31] - 2022-12-22

    Performance

    • Speed up parsing when a lot of different flags are present (100 unique flags)

    v4.0.30

    [4.0.30] - 2022-12-21

    Fixes

    • (error) Improve error for args_conflicts_with_subcommand
    Changelog

    Sourced from clap's changelog.

    [4.0.32] - 2022-12-22

    Fixes

    • (parser) When overriding required(true), consider args that conflict with its group

    [4.0.31] - 2022-12-22

    Performance

    • Speed up parsing when a lot of different flags are present (100 unique flags)

    [4.0.30] - 2022-12-21

    Fixes

    • (error) Improve error for args_conflicts_with_subcommand
    Commits
    • ec4ccf0 chore: Release
    • 13fdb83 docs: Update changelog
    • b877345 Merge pull request #4573 from epage/conflict
    • 85ecb3e fix(parser): Override required when parent group has conflict
    • d145b8b test(parser): Demonstrate required-overload bug
    • 0eccd55 chore: Release
    • 1e37c25 docs: Update changelog
    • dcd5fec Merge pull request #4572 from epage/group
    • dde22e7 style: Update for latest clippy
    • dd8435d perf(parser): Reduce duplicate lookups
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
Releases(v4.2.0)
Owner
null
A manifest.json generator

manifest-gen manifest-gen is a CLI tool that helps you in creating a manifest.json file for your pwa. Installation cargo install manifest-gen Usage ma

Fraol Lemecha 1 Jan 10, 2022
A collection of small Rust programs for doing weird things

This is a repo of small programs, proof of concepts, or templates written in Rust that relate in some way to hacking and/or CTF. I think Rust is real

d3npa 22 Nov 9, 2022
A small linktree style app using Yew.

Links This is a small website built using Yew. It uses trunk to run locally, and build for deployment. I wanted to explore this library and see how it

Josh Finnie 4 Aug 29, 2022
A version of `sort | uniq -c` with output that updates in real-time as each line is parsed

uniqtoo A version of sort | uniq -c with output that updates in real-time as each line is parsed. Usage Pipe something line-based into uniqtoo the sam

Jake Wharton 62 Oct 14, 2022
minimalistic command launcher in rust

rrun Note: Apart from the occasional fix, this project is not actively developed anymore. rrun works fine and should run/compile for the time being on

null 105 Nov 18, 2022
Performs distributed command execution, written in Rust w/ Tokio

Concurr: Distributed and Concurrent Command Execution, in Rust This project is dual licensed under MIT and Apache 2.0. Originally inspired by the GNU

Michael Murphy 93 Dec 18, 2022
The next gen ls command

LSD (LSDeluxe) Table of Contents Description Screenshot Installation Configuration External Configurations Required Optional F.A.Q. Contributors Credi

Pierre Peltier 9k Jan 2, 2023
Super-fast command aliases with arguments.

Bonnie Bonnie is a command aliasing tool. If you have a super-long command that you have to run all the time, Bonnie is for you! Just define the comma

arctic_hen7 58 Dec 22, 2022
A modern alternative to watch command

A modern alternative to watch command

Tavo Annus 7 Oct 7, 2022
jless is a command-line JSON viewer

jless is a command-line JSON viewer. Use it as a replacement for whatever combination of less, jq, cat and your editor you currently use for viewing JSON files. It is written in Rust and can be installed as a single standalone binary.

null 3.5k Jan 8, 2023
📺(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

??(tv) Tidy Viewer is a cross-platform CLI csv pretty printer that uses column styling to maximize viewer enjoyment.

Alex Hallam 1.8k Jan 2, 2023
Log agent to replay time-stamped log stream

replayman Log agent to replay time-stamped log stream. Getting started Installation cargo install replayman Prepare for your data TSV with a header li

SpringQL 3 Dec 23, 2022
Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

Rust Lean Image Viewer - Fast and configurable image viewer inspired by JPEGView by David Kleiner

3top1a 4 Apr 9, 2022
Small command-line tool to switch monitor inputs from command line

swmon Small command-line tool to switch monitor inputs from command line Installation git clone https://github.com/cr1901/swmon cargo install --path .

William D. Jones 5 Aug 20, 2022
A SARIF viewer for the command-line.

sarif_cli A SARIF viewer for the command-line. Because numerous static analysis tools, such as #CodeQL and #semgrep, use the SARIF format. I decided t

Jordy Zomer 3 Jan 3, 2023
A cross platform reloading image viewer combined with a command executor

Watchout A cross platform reloading image viewer combined with a command executor. Watchout will do any of the following: Run a command when any file

Benedikt Terhechte 6 Oct 7, 2022
A fast and simple command-line tool for common operations over JSON-lines files

rjp: Rapid JSON-lines processor A fast and simple command-line tool for common operations over JSON-lines files, such as: converting to and from text

Ales Tamchyna 3 Jul 8, 2022
Jq - Command-line JSON processor

jq jq is a lightweight and flexible command-line JSON processor. , Unix: , Windows: If you want to learn to use jq, read the documentation at https://

Stephen Dolan 23.9k Jan 4, 2023
This is a simple command line application to convert bibtex to json written in Rust and Python

bibtex-to-json This is a simple command line application to convert bibtex to json written in Rust and Python. Why? To enable you to convert very big

null 3 Mar 23, 2022