nukeop / nuclear

Streaming music player that finds free music for you
https://nuclear.js.org/
GNU Affero General Public License v3.0
11.72k stars 1.02k forks source link

Rotating log file for #1534 #1596

Open Kiduzk opened 2 months ago

Kiduzk commented 2 months ago

An implementation for #1534

nuki-chan[bot] commented 2 months ago

Lines 6-15

Ohayou, esteemed developer-san! Nuki has detected your intentions to improve logging, and while the effort is commendable, there are a few nuances that could make this even better! Let's tighten up those logs like we're prepping for the grand anime convention! 🌠

Here's a little code magic from Nuki to help out:

const logNameGenerator = (time, index) => {
  if (!time) return path.join(app.getPath('userData'), 'logs', 'nuclear-error.log');

  const month = time.getFullYear().toString() + (time.getMonth() + 1).toString().padStart(2, '0');
  const day = time.getDate().toString().padStart(2, '0');
  const hour = time.getHours().toString().padStart(2, '0');
  const minute = time.getMinutes().toString().padStart(2, '0');

  return path.join(app.getPath('userData'), 'logs', `${month}/${month}${day}-${hour}${minute}-${index}-nuclear-error.log`);
};

Lines 16-25

Lookie here! We're getting all fancy with rotating log files! 📜 But, there's always room for a little more polish, isn't there? Here are some hints from your code-review kouhai:

Remember, following Nuki's advice is like reading manga -- it's not required but it often leads to enlightenment, and occasionally, a good laugh. 😜 Also, Nuki might make a mistake sometimes, because even bots powered by the latest AI technologies can have bugs (but don't tell anyone, okay?). 🙊

Now, go forth and make these logs spectacular! Ganbatte, developer-chan! 💖✨

nukeop commented 2 months ago

Thanks for contributing. Let's discuss a couple of details in the comments

nukeop commented 2 months ago

Because you force-pushed to your branch, I can't push to your branch anymore, because the history is messed up and it's no longer continuous. Not sure how to add the tests I wrote to this PR.

Kiduzk commented 2 months ago

Hey @nukeop I apologize for the hassle I created with the force push. Is there a way we can fix it? Please let me know if you need me to do anything regarding the force push issue or the testing, I am more than willing to help. I would really appreciate your guidance if possible, I am kind of new to opensource stuff

nukeop commented 2 months ago

I tried to do several things and I have no idea how to fix this. I tried pushing to a parallel branch: https://github.com/nukeop/nuclear/tree/Kiduzk-temp But then I can't merge this branch into your master. Try it yourself, maybe you'll be able to.

In general you should never force push, especially to a branch others might be working on, it destroys git history. It's only allowable in cases where you commit important secrets that can't be rotated (even in those cases it's too late to protect these secrets anyway).

nukeop commented 2 months ago

Btw, the test on that branch is unfinished, and I'm not convinced it's going to be necessary. Maybe I could just merge this PR?

Kiduzk commented 2 months ago

As far as the testing goes, merging works with me. I run some manual tests with small log sizes and the output seems to be as we want it. This is one screenshot I have Screenshot from 2024-04-29 00-10-04

Kiduzk commented 2 months ago

Also, I was able to merge your branch with my master branch locally. Would you suggest that I push these changes to my GitHub fork associated with this PR?

nukeop commented 2 months ago

Yep, push them to this branch. If you do, I'll be able to add further commits

Kiduzk commented 2 months ago

Sounds good, I have pushed them

nukeop commented 2 months ago

Now that I pulled this locally, it seems to be fixed. Thanks.

nukeop commented 2 months ago

For some reason I still can't push to your branch. Could you please remove the last test in logger.test.ts and leave everything else? And then we could merge this PR.

Kiduzk commented 2 months ago

Sure, no problem. I have removed the last test, let me know if that works

nukeop commented 1 month ago

Can you remove the last test in that file? You only deleted some mocks. I wanted to do it myself but I still can't push to your branch.

Kiduzk commented 1 month ago

Yea, no problem. How about now