mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 22:39:52 +08:00
Merge pull request #4067 from yiisoft/better-log-target-failures
Fixes #3101: Improved handling of log target failures
This commit is contained in:
@@ -74,6 +74,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #2942: Added truncate and truncateWord methods (Alex-Code, samdark)
|
||||
- Enh #3008: Added `Html::errorSummary()` (qiangxue)
|
||||
- Enh #3088: The debug and gii modules will manage their own URL rules now (hiltonjanfield, qiangxue)
|
||||
- Enh #3101: Improved handling of log target failures. It will now skip target and log reason instead of going into infinite cycle (samdark)
|
||||
- Enh #3103: debugger panel is now not displayed when printing a page (githubjeka)
|
||||
- Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue)
|
||||
- Enh #3132: `yii\rbac\PhpManager` now supports more compact data file format (qiangxue)
|
||||
|
||||
@@ -175,10 +175,26 @@ class Dispatcher extends Component
|
||||
*/
|
||||
public function dispatch($messages, $final)
|
||||
{
|
||||
$targetErrors = [];
|
||||
foreach ($this->targets as $target) {
|
||||
if ($target->enabled) {
|
||||
try {
|
||||
$target->collect($messages, $final);
|
||||
} catch (\Exception $e) {
|
||||
$target->enabled = false;
|
||||
$targetErrors[] = [
|
||||
'Unable to send log via '. get_class($target) .': ' . $e->getMessage(),
|
||||
Logger::LEVEL_WARNING,
|
||||
__METHOD__,
|
||||
microtime(true),
|
||||
[],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($targetErrors)) {
|
||||
$this->dispatch($targetErrors, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user