• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter\Log and multiple handlers

#1
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.
Reply

#2
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% Smile
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#3
(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% Smile

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?
Reply

#4
(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?
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply

#5
(10-18-2019, 01:39 PM)kilishan Wrote: Not sure exactly what you mean. It already supports multiple loggers that can be [set up] Angel 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 = [
    'CodeIgniter\Log\Handlers\FileHandler' => 'Config\Logger\Handlers\FileHandler',
    // The ChromeLoggerHandler requires the use of the Chrome web browser
    // and the ChromeLogger extension. Uncomment the next line to use it.
    'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => 'Config\Logger\Handlers\ChromeLoggerHandler'
]; 

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. Big Grin
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.