From dd2407e347d651b3495d87ae1ee241fc00ead2eb Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Fri, 9 Sep 2016 00:39:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3?= =?UTF-8?q?=D1=83=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BE=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/components/ErrorHandler.php | 11 +++++++++++ api/config/main.php | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/api/components/ErrorHandler.php b/api/components/ErrorHandler.php index 54e8531..7ec29e7 100644 --- a/api/components/ErrorHandler.php +++ b/api/components/ErrorHandler.php @@ -3,6 +3,7 @@ namespace api\components; use api\modules\authserver\exceptions\AuthserverException; use api\modules\session\exceptions\SessionServerException; +use Yii; class ErrorHandler extends \yii\web\ErrorHandler { @@ -17,4 +18,14 @@ class ErrorHandler extends \yii\web\ErrorHandler { return parent::convertExceptionToArray($exception); } + public function logException($exception) { + if ($exception instanceof AuthserverException) { + Yii::error($exception, AuthserverException::class . ':' . $exception->getName()); + } elseif ($exception instanceof SessionServerException) { + Yii::error($exception, SessionServerException::class . ':' . $exception->getName()); + } else { + parent::logException($exception); + } + } + } diff --git a/api/config/main.php b/api/config/main.php index 96d093f..ef82de5 100644 --- a/api/config/main.php +++ b/api/config/main.php @@ -26,6 +26,24 @@ return [ [ 'class' => \yii\log\FileTarget::class, 'levels' => ['error', 'warning'], + 'except' => [ + 'legacy-authserver', + 'session', + 'api\modules\session\exceptions\SessionServerException:*', + 'api\modules\authserver\exceptions\AuthserverException:*', + ], + ], + [ + 'class' => \yii\log\FileTarget::class, + 'levels' => ['error', 'info'], + 'categories' => ['legacy-authserver'], + 'logFile' => '@runtime/logs/authserver.log', + ], + [ + 'class' => \yii\log\FileTarget::class, + 'levels' => ['error', 'info'], + 'categories' => ['session'], + 'logFile' => '@runtime/logs/session.log', ], ], ],