trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.18k stars 517 forks source link

parsing output #319

Open holdfenytolvaj opened 8 years ago

holdfenytolvaj commented 8 years ago

it might worth to mention on the front page that there is a nice tool to parse json output, so one can easily search/filter on the output...

https://stedolan.github.io/jq

mlucool commented 8 years ago

:+1:

cflynn07 commented 8 years ago

I also like https://github.com/trentm/json

Using: node index.js | bunyan -o json --strict | json -d ' -|- ' -ga module msg

I can get output similar to:

lib/middlewares/me.js -|- isUser                                                                                                                  
lib/middlewares/me.js -|- checkUserIdsMatch                                 
lib/middlewares/me.js -|- checkUserIdsMatch - no match                                                                                             
lib/middlewares/domains.js -|- middlewares/domains res.send                                                                                           
lib/routes/github/index.js -|- proxying the request

Is there any interest in adding an output fields filter to the bunyan cli?

trentm commented 8 years ago

Thanks for the question.

@cflynn07 Heh, I like json too (I wrote it :).

jq is cool too. Yes, I think having some cookbook-type thing for Bunyan usage would be a good idea. I.e. examples of things one can do with it: with bunyan, code usage patterns, with json and jq. However, that gets to the tipping point for having more than just the README for node-bunyan.

Anyway, a mention of json and jq in the rEADME would definitely be a good idea.

@cflynn07 About bunyan CLI options to filter fields: I think for your example use case above, I'd rather cut the call to bunyan out of the picture and just have json support not blowing up on non-JSON lines: https://github.com/trentm/json/issues/90

cflynn07 commented 8 years ago

@trentm Yeah having JSON gracefully handle non-json lines would be great. +1