nuclear
nuclear copied to clipboard
Use a rotating log file in addition to logging to the console
The log file needs to be stored in the same directory as the config files and never exceed 1-2MB.
Can you please provide few more details about this issue, i am new here so i would love to contribute on this @nukeop
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.
The number of log files and the limit should both be customizable.
and from where it should be controlled?
For now, it can be hardcoded in the logger initialization code.
Hi @Tweniee, are you still working on this issue?
Can I work on this if it is not resolved yet? Looks like there has been no activity since a while
Sure, go ahead!
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:
- Have some hardcoded config in the
index.tsfile in theloggercomponent in themainpackage. - 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?
- By logs, does it include all logs like errors, warnings and events?
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.
Got it! Thanks, will let you know if I have any more questions.
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)
Sounds good if you can make it work with the current logging mechanism.
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.
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.
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.