awesomeeng / awesome-log

Logging for enterprise ready nodejs applications.
MIT License
34 stars 4 forks source link

Month formatting for file writer #28

Open jvonehr opened 1 year ago

jvonehr commented 1 year ago

I found a minor problem in logging to file in the formatter. The “MM” string formats October month number as “91”.

File: DateFormatParser Line 108: return (""+date.getUTCMonth()+1).padStart(2,"0”); Incorrectly formats October as “91” Should be: return (""+(date.getUTCMonth()+1)).padStart(2,"0");

Also, another minor thing: writers override: filename: "logs/Logs{YYYY.MM}/Log{YYMMDD}_{HHmm}.log" results in an extra directory level - creates: logs/logs/Logs_2022.10/Log_221014_1207.log (leaving off the first "log/" in format results in: Logs_2022.10/Log_221014_1209.log) Your documentation example: "You may have multiple patterns in a filename pattern string, for example: /logs/{YYYY}/{MM}/{DD}/MyLog.{HH}.log" throws an error -2 from mkdir.

The links to your documentation on npm.io seem broken, but github docs are somewhat better (links under Log Writers are broken).

If I knew how, I’d submit a PR, but I’ll bet you can fix it faster than I could figure out how to do that…

Thanks again.