orangain / pretty-json-log-plugin

IntelliJ plugin to pretty print JSON lines logs.
https://plugins.jetbrains.com/plugin/24693-pretty-json-log
MIT License
10 stars 4 forks source link

Pretty JSON Log plugin

Build Version Downloads

Plugin screenshot

Pretty JSON Log plugin for IntelliJ Platform makes NDJSON (Newline Delimited JSON a.k.a. JSON Lines) logs more readable in the console. It has the following features:

This plugin is useful when you are developing a modern system that outputs logs in JSON format. You no longer need to switch log formats between production and local development environments.

Installation

After installation, newly written JSON lines logs in the console will be automatically formatted by the plugin.

Limitations

JetBrains IDEs provide different kinds of consoles for different run configurations, but this plugin does not currently support all consoles due to the lack of extension points in the IDE. If the console does not have the context menu item "Pretty JSON Log", the plugin is not supported in that console.

Context menu item with text 'Pretty JSON Log'

How to see the debug log of the plugin

  1. Help > Diagnostic Tools > Debug Log Settings....
  2. Add line #io.github.orangain.prettyjsonlog to the text area of the dialog and click OK.
  3. Reproduce the issue.
  4. Help > Show Log in Finder/Explorer to open the log directory.
  5. Open the idea.log file and find the log of the plugin by searching for #io.github.orangain.prettyjsonlog.

Enabling debug logging may slow down the IDE, so it is recommended to disable it after reproducing the issue.

Acknowledgements

This plugin is inspired by the pino-pretty and bunyan CLI. The great idea behind these tools is that applications should write logs in machine-readable format (JSON) and pretty-printing for human readability should be done by another tool. I am grateful to the authors of these tools.

Thanks to the IntelliJ Platform Plugin Template, I was able to quickly start developing the plugin.