CodeIgniter\Log and multiple handlers |
I'm curious why CodeIgniter\Log::log() is designed such that if one handler returns false it won't continue with any other handlers in the queue?
It seems to me that it would be a good thing that if the (theoretical) EmailHandler failed to send an email that the FileHandler would still write to a log file.
Very good point. And probably just an oversight. Please remember that a good 1/2 of this framework was written by me at midnight, fueled by coffee, when my body said I should be sleeping, so there might be some logic issues that weren't sorted 100%
(10-18-2019, 06:47 AM)kilishan Wrote: Very good point. And probably just an oversight. Please remember that a good 1/2 of this framework was written by me at midnight, fueled by coffee, when my body said I should be sleeping, so there might be some logic issues that weren't sorted 100% No need to apologize. I wanted to be sure I wasn't missing something that, if I hadn't been so tired, would be obvious. I'm playing with the idea of implementing a setup much like $passwordValidators in myth-auth. The current logger is halfway there already. Thoughts? (10-18-2019, 10:45 AM)dave friend Wrote: I'm playing with the idea of implementing a setup much like $passwordValidators in myth-auth. The current logger is halfway there already. Thoughts? Not sure exactly what you mean. It already supports multiple loggers that can be setup to log individual log levels. What tweaks were you thinking?
(10-18-2019, 01:39 PM)kilishan Wrote: Not sure exactly what you mean. It already supports multiple loggers that can be [set up] to log individual log levels. What tweaks were you thinking? Primarily moving the handler configs into distinct classes and changing the $handlers property of Config\Logger\Logger to simply be the list of handlers that are executed, e.g. PHP Code: public $handlers = [ The key is obvious (I think) and the value is the config file for the handler class. There's probably a better way to supply the handler config and I would really like some feedback on the above. A question: What's the usefulness in having CodeIgniter\Log\Logger::log() return a boolean? I don't see the return as a problem, but I also don't see the point. I cannot find where the return is used anywhere in the core or the App namespace. I was thinking of changing the return to void. I don't think CodeIgniter\Log\Logger will require much refactoring. However, I was wondering if it might be easier to instantiate the handlers in the constructor. Then when it came time to run Logger::log() all you have to do is iterate through the list of cached handler instances calling handle() on each in turn. Oh, and I would not stop processing the handler list if one of them returns false. I started exploring the Logger to see about handling Logger Path Duplicated #2286 and now I'm in up to my elbows. |
Welcome Guest, Not a member yet? Register Sign In |