katzgrau/KLogger

Klogger creates empty file even if not used to log() anything

johnykvsky opened this issue · 0 comments

After playting with Slim (middleware and stuff) I noticed that when logger is created and even not used, a log file is created with zero size. Construct run setFileHandle() witch do fopen(...,'a') and this creates empty file, even if I don't log() anything (on PHP7 to be precise).

First I thought of moving setFileHandle() outside constructor or playing with different than 'a' file open modes, but then - why not use file_put_contents. It won't create file until it try to write to it, performance is (according to google) the same.

Do you see any drawbacks of it? Change was quite easy, code got cleaner. If you want, I can make a PR.