katzgrau / KLogger

A Simple Logging Class For PHP
http://codefury.net/projects/klogger/
981 stars 284 forks source link

Different log files in same class #62

Closed SerikDM closed 9 years ago

SerikDM commented 9 years ago

What about having different log files? i.e. to have one file for database logs, another for payment services, another for core issues, and so on?

katzgrau commented 9 years ago

Why not different instances of KLogger?

onno-vos-dev commented 9 years ago

Damn Kenny you were fast! Different instances of Klogger should do the trick. Implementing different log files inside Klogger would require a lot of modifications and break PSR standards on multiple function calls.

SerikDM commented 9 years ago

onno-vos-dev thank you for your comment. I was afraid of high memory usage.

onno-vos-dev commented 9 years ago

Klogger is pretty memory friendly :) I think you'd have more memory issues at other places of your code than Klogger. I have used Klogger to generate enormous logfiles containing millions of rows with no performance issues whatsoever :)

katzgrau commented 9 years ago

I was following the convo, but out of pocket until now ;)

Re memory usage, I'd say the (negligible) memory usage issue is outweighed by the annoyance of a developer having to do something like:

$logger->debug('database', 'Some log line.');
// as opposed to
$dblog->debug('Some log line');

It's small, but having an extra parameter everywhere would get old quickly. Plus a wrapper class would take 10 minutes to write and serve your needs perfectly. But as @onno-vos-dev said, the bigger issue is the PSR standard.