Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a rotating log file in addition to logging to the console #1534

Open
nukeop opened this issue Dec 4, 2023 · 15 comments
Open

Use a rotating log file in addition to logging to the console #1534

nukeop opened this issue Dec 4, 2023 · 15 comments
Labels
enhancement This thread requests an enhancement to be implemented. good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time.

Comments

@nukeop
Copy link
Owner

nukeop commented Dec 4, 2023

The log file needs to be stored in the same directory as the config files and never exceed 1-2MB.

@nukeop nukeop added enhancement This thread requests an enhancement to be implemented. good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time. labels Dec 4, 2023
@Tweniee
Copy link

Tweniee commented Dec 5, 2023

Can you please provide few more details about this issue, i am new here so i would love to contribute on this
@nukeop

@nukeop
Copy link
Owner Author

nukeop commented Dec 5, 2023

The logs from the main process and the renderer process need to be saved to a file with a capped size. When the limit is reached, a new file needs to be created. When the limit in that file is reached, the next log should clear the oldest log file and start saving there. The number of log files and the limit should both be customizable.

@Tweniee
Copy link

Tweniee commented Dec 5, 2023

The number of log files and the limit should both be customizable.

and from where it should be controlled?

@nukeop
Copy link
Owner Author

nukeop commented Dec 5, 2023

For now, it can be hardcoded in the logger initialization code.

@RyanMurphy1014
Copy link

Hi @Tweniee, are you still working on this issue?

@thathva
Copy link

thathva commented Mar 1, 2024

Can I work on this if it is not resolved yet? Looks like there has been no activity since a while

@nukeop
Copy link
Owner Author

nukeop commented Mar 1, 2024

Sure, go ahead!

@thathva
Copy link

thathva commented Mar 7, 2024

Hey @nukeop!
I was a bit occupied trying to set the dev environment and was able to set it up.
I have couple of questions about the requirements. If I understood it right:

  1. Have some hardcoded config in the index.ts file in the logger component in the main package.
  2. Have a check that if the specified limit has been exceeded, create new files and start saving to this file. My question is what would happen to the older files? Would we be overwriting those files or just leave it to the user to clean it up if necessary?
  3. By logs, does it include all logs like errors, warnings and events?

@nukeop
Copy link
Owner Author

nukeop commented Mar 7, 2024

We're using electron-timber to differentiate logs coming from the main and renderer processes. Don't implement your own rotation system, see if you can use an existing package and integrate it with timber. Whatever timber logs should be saved into the log file. I think a decent default will be 3 files, 1MB each, when the last log reaches its limit, start saving to the first one again.

@thathva
Copy link

thathva commented Mar 7, 2024

Got it! Thanks, will let you know if I have any more questions.

@thathva
Copy link

thathva commented Mar 8, 2024

The rotating-file-stream package seems to have the functionality of maxFiles and a custom generator function that can be used to "rotate" files. All it needs is an index. I have tried it on a high level and it seems to create the new files of upto the specified size limit. I am yet to figure out passing the index and rewrite to the older log files (it uses timestamps as of now). Does this sound like a good approach so far?
(https://www.npmjs.com/package/rotating-file-stream#filenametime-index)

@nukeop
Copy link
Owner Author

nukeop commented Mar 8, 2024

Sounds good if you can make it work with the current logging mechanism.

@thathva
Copy link

thathva commented Mar 14, 2024

I think this task can be taken up by any other person that is available. I am having a difficult time with the development environment, even though I am on Linux (mostly system specifications - low end PC). My findings that can help anyone:

I wasn't able to find any library that does the rotation, by files at least. I was able to make it work a little bit with the rotating-file-stream library itself, but that still needs more customization in the custom function to generate new files. The library does create new files, but the index was getting messed up, so it would create way too many files.

@Kiduzk
Copy link

Kiduzk commented Apr 21, 2024

Hey @nukeop, I am new here and would like to work on this issue if it is still available. As of right now, I am thinking to continue @thathva's approach with using the rotating-file-stream and try to get the index to work properly in the generate function.

@nukeop
Copy link
Owner Author

nukeop commented Apr 21, 2024

Okay! There's been a bunch of people announcing they're working on this, then doing nothing. I think we've got the approach down already. All that's needed is a pull request, in any shape - we can iterate the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This thread requests an enhancement to be implemented. good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time.
Projects
None yet
Development

No branches or pull requests

5 participants