mongodb-memory-server icon indicating copy to clipboard operation
mongodb-memory-server copied to clipboard

Pretty Print MongoDB server output

Open hasezoey opened this issue 3 years ago • 15 comments

for mongodb 4.4, they have changed to use logs as json, currently we are printing them as-is, but it is pretty hard to debug as they are

this is a tracking issue for pretty printing this new log output

implementation details:

  • only process the lines when debug mode is enabled (for the MongoInstance file)
  • process each new line separately
  • process JSON into something resembling like the old log format
  • have a flag to disable this pretty-printing (because this can be really resource intensive)

also, a alternative could be to write something to read in the finished log and colorize and sort it for faster debugging

hasezoey avatar Jan 18 '22 11:01 hasezoey

Hi @hasezoey! if no one is picking this issue i can pick this.

aryabharat avatar Jan 12 '23 09:01 aryabharat

if no one is picking this issue i can pick this.

you can try if you want to, i would recommend reading CONTRIBUTING first

hasezoey avatar Jan 12 '23 11:01 hasezoey

Hey Hi!! @hasezoey I would like to work on this issue if possible. I have used TypeScript for the past some time. However I am not quite that very great at it, so would you advise me to work on it or would it be a bit out of my reach.

Aspireve avatar May 22 '23 17:05 Aspireve

@Aspireve you can work on it and open a PR (probably in DRAFT mode), you can also join our discord and ask questions there

hasezoey avatar May 22 '23 18:05 hasezoey

Ohh Awesome!! I'll start by going over the CONTRIBUTING file and skimming over the code (PS I joined the Discord Server)

Aspireve avatar May 22 '23 19:05 Aspireve

Heyy @hasezoey!! Could you explain this issue. I actually wasn't able to quite understand it. Do I actually have to make the pretty format only when in debugging? Also does it have to be done to the output or just the console logs? (PS I currently forked the repository an will create a DRAFT PR soon)

Aspireve avatar May 23 '23 04:05 Aspireve

Do I actually have to make the pretty format only when in debugging?

yes, because i assume doing JSON.parse over many lines so often will be quite a performance hit, especially when the logs arent even shown anywhere (they are only shown / printed when debugging is on)

Also does it have to be done to the output or just the console logs?

i dont quite understand the question, the logs from mongodb output in MongoInstance.stdoutHandler would have to be parsed for every line (and maybe also .stderrHandler)

hasezoey avatar May 23 '23 08:05 hasezoey

Ohh Ok, I got what you are saying!! Thanks!!

Aspireve avatar May 24 '23 02:05 Aspireve

Hey also @hasezoey should I fork it and create a new branch in my repo and work there or should I just clone this repo and work on the beta branch? Cause I guess it not mentioned in the CONTRIBUTING.md

Also should I create an Issue about the same so that someone else could solve it later?

Aspireve avatar May 24 '23 11:05 Aspireve

Hey also @hasezoey should I fork it and create a new branch in my repo and work there or should I just clone this repo and work on the beta branch?

it does not matter which branch you work on as long as it is a fork, the only thing to keep in mind is if you want to keep the main branches of the main repo and your fork in sync, you will have to fore-push to your repo

Also should I create an Issue about the same so that someone else could solve it later?

no i dont think that is required

hasezoey avatar May 24 '23 11:05 hasezoey

Ohh cool!! Also how do I setup this project and run it?

Also TypeScript is shooting some weird errors in other files than the core module image

(Sorry a lot of questions lol)

Aspireve avatar May 24 '23 12:05 Aspireve

@Aspireve those questions are not related to the issue at hand, please ask them in discussions or preferably on discord

*if any of the questions are non-specific, they may get added to CONTRIBUTING or some other place


as for how to run the project (tests) run either in root yarn run test or in packages/mongodb-memory-server-core/ yarn run coverage (or also just test, but coverage is faster because it does not do extra steps)

hasezoey avatar May 24 '23 12:05 hasezoey

as for how to run the project (tests) run either in root yarn run test or in packages/mongodb-memory-server-core/ yarn run coverage (or also just test, but coverage is faster because it does not do extra steps)

Ohh cool!! Thanks!!

Aspireve avatar May 24 '23 12:05 Aspireve

Hey after running coverage it's begun installing 2-3 MongoDBs with very different versions, is it the correct method of working or am I doing something completely wrong lol

Aspireve avatar May 24 '23 13:05 Aspireve

@Aspireve like i said, this is not part of this issue, please keep it to github discussions or preferably our discord

and yes, that is expected and normal

hasezoey avatar May 24 '23 13:05 hasezoey