GithubHelp home page GithubHelp logo

gurland / json-log-viewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hedhyw/json-log-viewer

0.0 0.0 0.0 2.72 MB

Interactive viewer for JSON logs.

License: MIT License

Go 98.97% Makefile 1.03%

json-log-viewer's Introduction

JSON Log Viewer

Version Build Status Go Report Card Coverage Status

It is an interactive tool for viewing and analyzing complex structured json-log files.

Animation

Main features:

  1. It is interactive.
  2. It displays a compact list of log entries.
  3. It is possible to expand the log and see the full prettified JSON tree.
  4. All non-json logs are captured.
  5. Fields are customizable.
  6. Filtering is easy to use.
  7. Log levels are colorized.
  8. Transforming numeric timestamps.

It uses antonmedv/fx for viewing JSON records and charmbracelet/bubbletea for organizing the terminal UI. The tool is inspired by the project json-log-viewer which is unfortunately outdated and deserted.

The application is designed to help in visualization, navigation, and analyzing of JSON-formatted log data in a user-friendly and interactive manner. It provides a structured and organized view of the JSON logs, making it easier to comprehend the hierarchical nature of the data. It uses collapsible/expandable tree structures, indentation, and color-coded syntax to represent the JSON objects and arrays. It is possible to search for specific keywords, phrases, or patterns within the JSON logs. So it helps to significantly simplify the process of working with JSON logs, making it more intuitive and efficient. It is easy to troubleshoot issues, monitor system performance, or gain a deeper understanding of the application's behavior by analyzing its log data in post-mortem.

Table of content

Usage

jlv file.json
Key Action
Enter Open/Close log
F Filter
Ctrl+C Exit
F10 Exit
Esc Back
↑↓ Navigation

[↑] Click Up on the first row to reload the file.

Install

MacOS/Linux HomeBrew

brew install hedhyw/main/jlv
# jlv application.log

Go

go install github.com/hedhyw/json-log-viewer/cmd/jlv@latest
# jlv application.log

Package

Latest DEB and RPM packages are available on the releases page.

Standalone Binary

Download latest archive *.tar.gz for your target platform from the releases page and extract it to /usr/local/bin/jlv. Add this path to PATH environment.

Source

git clone [email protected]:hedhyw/json-log-viewer.git
cd json-log-viewer
make build
cp ./bin/jlv /usr/local/bin
chmod +x /usr/local/bin/jlv

# jlv application.log

Customization

The application will look for the config .jlv.jsonc in the working directory or in the home directory:

  • $PWD/.jlv.jsonc;
  • $HOME/.jlv.jsonc.

The Json path supports the described in yalp/jsonpath syntax.

Example configuration:

{
    // Comments are allowed.
    "fields": [
        {
            "title": "Time", // Max length is 32.
            // Kind affects rendering. There are:
            // * time;
            // * numerictime;
            // * secondtime;
            // * millitime;
            // * microtime;
            // * level;
            // * message;
            // * any.
            "kind": "numerictime",
            "ref": [
                // The application will display the first matched value.
                "$.timestamp",
                "$.time",
                "$.t",
                "$.ts"
            ],
            "width": 30
        },
        {
            "title": "Level",
            "kind": "level",
            "ref": [
                "$.level",
                "$.lvl",
                "$.l"
            ],
            "width": 10
        },
        {
            "title": "Message",
            "kind": "message",
            "ref": [
                "$.message",
                "$.msg",
                "$.error",
                "$.err"
            ],
            "width": 0 // The width will be calculated automatically.
        },
        {
            "title": "Custom",
            "kind": "any",
            "ref": [
                "$.custom"
            ],
            "width": 0
        }
    ]
}

Time Formats

JSON Log Viewer can handle a variety of datetime formats when parsing your logs.

time

This will return the exact value that was set in the JSON document.

numerictime

This is a "smart" parser. It can accept an integer, a float, or a string. If it is numeric (1234443, 1234443.589, "1234443", "1234443.589"), based on the number of digits, it will parse as seconds, milliseconds, or microseconds. The output is a UTC-based RFC 3339 datetime.

If a string such as "2023-05-01T12:00:34Z" or "---" is used, the value will just be carried forward to your column.

If you find that the smart parsing is giving unwanted results or you need greater control over how a datetime is parsed, considered using one of the other time formats instead.

secondtime

This will attempt to parse the value as number of seconds and render as a UTC-based RFC 3339. Values accepted are integer, string, or float.

millitime

Similar to secondtime, this will attempt to parse the value as number of milliseconds. Values accepted are integer, string, or float.

microtime

Similar to secondtime and millistime, this will attempt to parse the value as number of microseconds. Values accepted are integer, string, or float.

Resources

Alternatives:

  • mightyguava/jl - Pretty Viewer for JSON logs.
  • pamburus/hl - A log viewer that translates JSON logs into human-readable representation.
  • json-log-viewer - Powerful terminal based viewer for JSON logs using ncurses.

Contribution

Check open unassigned issues, write comments, ask questions, fork, and create a pull request.

License

MIT License.

json-log-viewer's People

Contributors

cosmastech avatar dependabot[bot] avatar gurland avatar hedhyw avatar mihai22125 avatar vedu1996 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.