Hi
Simetimes a user is able to produce an excpetion. However, that happens in production and is hard to retrace.
I have EmailTarget enabled which is for errors only. Exists a way to include ALL logged events in order to that email? The normal FileTarget only includes error and warnings, no info and no debug.
Or even better: Some systems generate a “number” which holds more information about the occured error. Would be great if I were able to look into the debug-console in the case when an exceptions was raised.
Thanks to @CeBe who had a nice idea for this. One could simply overwrite the EmailTarget::export() function to check each messages level. If at least one message matches my criteria, the parent export will be called. Otherwise the messages will be discarded.
Note, that all/none levels must be configured then.
components/EmailTarget
<?php
namespace common\components;
use yii\log\Logger;
class EmailTarget extends \yii\log\EmailTarget {
public function export() {
foreach ( $this->messages as $message ) {
if ( $message[1] <= Logger::LEVEL_ERROR ) {
return parent::export();
}
}
return false;
}
}