Saturday 24 November 2018

Options for reading (winston-like) json objects from an application log?

tl:dr; i'm dumping json objects into a log file, server-side. what's out there for legibly presenting me that information through a simple node module? i'm open to serving it out to the browser but am leaning towards something at the command line so i don't have that security hole to patch up.i've inherited a project developing an ionic app and (unfortunately) a python server. the python server is basically a proxy to a third-party SOAP API and after some whittling, it's only real responsibility is to capture logs for debugging.the logic for dropping the requests and responses into the log a legible way was slowly getting out of hand, and the 12-factor app principle of dumping everything into a pipe for possible eventual consumption has been making more and more sense.meanwhile, i've started using winston for logging in the app and love it. 12-factor seems to hinge on the developer being able to pick through the logs for what's relevant but i've opted for a couple reporters that scrape the events, assemple them as needed (like matching requests to their responses) and show me what i'm looking for. i can look at events that were fired, api calls, snapshots from form submissions, etc. -- or just look at them in one big list. but with the browser at my disposal (i pop a new window) those lists are basically tall rectangles with dressed up object dumps stacked left-to-right -- so side-scrolling over past a long entry doesn't take any longer than a short one.anyway, i'm probably getting off topic so back to the server logs: i've switched them to dump json objects to the log file as winston would and assumed there would be existing options out there for what i'm trying to accomplish ,which is kind of open ended but boils down to "let me quickly read the end of the log file to debug issues".for now i've written a small utility that handles it but doesn't watch the log file -- i have to run it and it shows the last 50 logs (or whatever i've changed that variable to). i can certainly build on it and enjoy having my first excuse to use chalk, but i get the feeling i'm reinventing the wheel.i did find one npm package that i can't seem to find today that looked very promising, is built on ncurses and uses hotkeys for navigation. i ran into an error with that one and may poke into it, but i'm on Windows and have no idea whether that means ncurses is available. all i know about ncurses is that it somehow, you know, makes the console look way different from a CLI. and all i know about Cmd.exe is that it's the worst. linux is in my past and future but unfortunately not the immediate present due to the circumstances.

Submitted November 24, 2018 at 06:21PM by daveequalscool

No comments:

Post a Comment