-
☆ A M B ☆
- 24,524 Posts
I don't think that there is an event for that. Writing to the log is an API function, and there are levels of log entries.
However, if this is still applicable you should be able to write your own error handler.
https://forums.modx.com/thread/29142/error-handling-and-error-logging-in-php-code-in-modx-revolution
http://rtfm.modx.com/xpdo/2.x/class-reference/xpdo/xpdo.log
-
☆ A M B ☆
- 24,524 Posts
Check out core/model/modx/error/moderror.class.php and its implementation in core/model/modx/error/moderrorhandler.class.php
I'm not sure how you would specify a custom error handler, possibly by creating a system setting? In core/model/modx/modx.class.php it does appear to be possible to do so - in line 1383 it looks for a 'error_handler_class' System Setting and uses the class from error/moderrorhandler.class.php as the default:
if (!isset ($this->config['error_handler_class']))
$this->config['error_handler_class']= 'error.modErrorHandler';
You could probably also set it in a plugin.
The complete event list is here:
http://bobsguides.com/modx-revolution-events.html, but I agree with Susan that there isn't one, though it's not a bad feature request.
You could add code to the log() method but it would be overwritten when you upgrade MODX, so as Susan says, the best approach is to create your own error handler, have it do your stuff, and then have it either write to the error log or call the existing handler.
-
☆ A M B ☆
- 24,524 Posts
I would just clone moderrorhandler.class.php to mymoderrorhandler.class.php, and edit it to add what I needed. That way it would still do all the normal stuff after it did my stuff.
Great idea. Much better than mine.
-
☆ A M B ☆
- 24,524 Posts
Well, I'm lazy, and I would have to do some digging to figure out how to call the default handler from my custom handler. I'm sure there's an obvious way to do that...probably something like extend the default class, have my extended class do my stuff, then have something to call the parent class. Like what the default one does already, maybe?
parent :: _log($level, $msg, $target, $def, $file, $line);
-
☆ A M B ☆
- 24,524 Posts
What does this mean
* For detailed information on using this class, see {@tutorial modx/modx.pkg}.
That's a somewhat difficult concept for an extra package, if that's what you're considering. The user may already have installed his or her own error handler, so your package would probably have to try to detect that in order to be well-behaved.