megahertz / electron-log

Simple logging module Electron/Node.js/NW.js application. No dependencies. No complicated configuration.
MIT License
1.31k stars 127 forks source link

Infinite loop log writing (file and console transport) #438

Open ivan-kzkv opened 1 week ago

ivan-kzkv commented 1 week ago

Sorry if it's silly question. I have a project and set log methods through it. in main.electron.ts file in global scope I have this kind of initialize procces and all work fine. log.transports.file.level = 'info'; log.initialize(); log.transports.file.resolvePathFn = () => path.join(__dirname, '../dataDir/logs/main.log');

but when I try to save logs in project folder like this: log.transports.file.level = 'info'; log.initialize(); log.transports.file.resolvePathFn = () => path.join(__dirname, '/logs/main.log');

any first log in my application start infinite loop of log writting. And I cant figure why its work like this. Thanks for your answer.

megahertz commented 1 week ago

Have you changed some other logger settings somewhere else? Or maybe you bound logger methods to the console or some other object?

I can't reproduce the issue even if I set another path to which the app has no access. I would appreciate it if you could make a test project that reproduces the issue.

ivan-kzkv commented 1 week ago

It's legacy project I investigated it but didn't find any code that could affect this behaviour. I will try to make test project with controlled conditions.

megahertz commented 1 week ago

BTW, usually, that's not a good idea to set the log file location to __dirname. At least, it will work differently than expected when the app is packaged in many cases.

ivan-kzkv commented 1 week ago

I know, but it was done with my college and he found that issue and it's intresting to me how this works