orangain / pretty-json-log-plugin

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

Formatting issue #49

Open milenayk opened 1 month ago

milenayk commented 1 month ago

If I have a json with very very long value, plugin doesn't format it. Could you provide some solution? Example: {"message":"Communication error","timestamp":"2024-07-25 17:12:30.917","severity":"ERROR","exception":"com.test.common.exception.BaseRuntimeException: Communication error\r\n\tat com.test.common.handler.RestAPIExceptionHandler.doOnError(RestAPIExceptionHandler.java:64)\r\nCaused by: org.apache.thrift.transport.TTransportException: HTTP Response code: 500\r\n\tat org.apache.thrift.transport.THttpClient.flush(THttpClient.java:379)\r\n","stackTrace":"--------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------\r\n----------------------------------------------------------------\r\n---------------------------------------------------------------------------------------\r\n----------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------\r\n---------------------------------------------------\r\n-----------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------\r\n---------------------------------------------------------------------\r\n---------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------\r\n-----------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------------------------\r\n--------------------------------------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------\r\n------------------------------------------------------------------------------------------------\r\n----------------------------------------------------------------------------\r\n-----------------------------------------------------------------------------------------------------------------\r\n-------------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n---------------------------------------------------------------------------------------------------------\r\n------------------------------\r\n","pid":"36812","thread":"http-nio-8084-exec-1","class":"com.test.common.handler.RestAPIControllerAdvice","context":"default","logger":"c.t.c.handler.RestAPIControllerAdvice","method":"logError","file":"RestAPIControllerAdvice.java","line":"234","mdc":"traceId=8fe1379464435b33, spanId=8fe1379464435b33, spanExportable=true, X-Span-Export=true, X-B3-SpanId=8fe1379464435b33, X-B3-TraceId=8fe1379464435b33"}

orangain commented 1 month ago

@milenayk Thank you for reporting the issue! I found that when a very very long line is written to the console, the entire line is not passed to the plugin at once, but the line is passed in several little pieces. Because of this, the plugin will not recognize valid JSON and will not format it.

Perhaps it might be possible to recognize valid JSON by buffering the string passed to the plugin, but buffering carries the risk that the string will not be output correctly. Please give me some time to think of a good solution.