katzgrau / KLogger

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

Ability to change the logFormat on the fly #72

Closed ghost closed 8 years ago

ghost commented 8 years ago

Just a simple method like public function setLogFormat($pFormat); to give the ability to change the format after the object creation.

public function setLogFormat($pFormat)
{
    $this->options["logFormat"] = $pFormat;
}

e.g. After the user has accepted the terms of use, the ip-address or the username could be added to the logformat without creating a new logger object.

ghost commented 8 years ago

Still no answer :cry:

katzgrau commented 8 years ago

Yea, been thinking about this. In regard to:

"After the user has accepted the terms of use, the ip-address or the username could be added to the logformat without creating a new logger object."

If the use case is for a webapp, wouldn't it involve creating a new logger object anyway, since it's a separate request? The old logger object is disposed of after the request. Am I missing something?

katzgrau commented 8 years ago

Closing, unless you've got a reason to reopen

ghost commented 8 years ago

That was just an example. In my case I dont change the log writer object because its annoying to always share the configuration to each new logger instance. Instead of that I change the logformat using the function I've shown before. To implement that method I needed to change the klogger class because I wasnt able to extend a new class from the klogger class (same problem as mentioned here:https://github.com/katzgrau/KLogger/issues/73, because the file handle is declared as private)

I dont see a point against this method. It just extends the functionality without changing the concept behind Klogger.