I have to review lots of java logs from various sources, that contain java objects dumped to a single long line. Sometimes I'd like to see them in a more formatted fashion. Note that I'm not in control of the logging or the logs I receive.
Are there any command line tools that will format these types of objects nicely? I'm not looking for perfectly, but something like json formatting?
A sample object
[sampleObject{objId=c1, request=sampleRequest(bean=bean1, method=method1), env=job(pattern=*), step=1, state=SUCCESS}, sampleObject{objId=c2, request=sampleRequest(bean=bean1, method=method1), env=job(pattern=*), step=1, state=SUCCESS}, sampleObject{objId=c2, request=sampleRequest(bean=bean1, method=method2), env=job(pattern=*), step=2, state=SUCCESS}, sampleObject{objId=c3, request=sampleRequest(bean=bean1, method=method1), env=job(pattern=*), step=1, state=SUCCESS}, sampleObject{objId=c3, request=sampleRequest(bean=bean1, method=method2), env=job(pattern=*), step=2, state=SUCCESS}]
Sample desired output
[
sampleObject{
objId=c1,
request=sampleRequest(
bean=bean1,
method=method1
),
env=job(
pattern=*
),
step=1,
state=SUCCESS
},
sampleObject{
objId=c2,
request=sampleRequest(
bean=bean1,
method=method2
),
env=job(
pattern=test
),
step=2,
state=SUCCESS
},
]
jqgenerates a parsing error (sojqwon't be an 'easy' solution); the sample input has 5xsampleObject{...}blocks while the expected output only has 2x such blocks (can't tell if this is a typo or if we're missing instructions on how to filter out desired blocks); sample input ends with}]but the expected output ends with},](can't tell if this is a typo or we're supposed to 'add' to the data);[and{are followed by 2-char indents while(is followed by 4-char indents (variable indent req's?); so ....awk,perl,java, etc) to do the pretty-printing; wrapping in a (bash) function would make it easier to call (either on a line-by-line basis or processing a whole log file at once)objId=c3is missing, idk what else is different) so we can't test a potential solution with it. Make sure the minimal reproducible example you post is exactly that so it's as easy as possible for people to help you.