From b0a4a9b31cb135ca169a2a88ae2c87502b8ca354 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 22 Mar 2016 17:14:40 +0200 Subject: [PATCH] Cleaning up log files --- app/Http/Controllers/PaymentController.php | 2 +- app/Http/routes.php | 2 +- app/Libraries/Utils.php | 8 ++++++-- app/Ninja/Mailers/Mailer.php | 2 +- bootstrap/app.php | 5 +++++ 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 1ba681ba57..ebede5711b 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -642,6 +642,6 @@ class PaymentController extends BaseController $message .= $error ?: trans('texts.payment_error'); Session::flash('error', $message); - Utils::logError("Payment Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message)); + Utils::logError("Payment Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message), 'PHP', true); } } diff --git a/app/Http/routes.php b/app/Http/routes.php index e014579095..eeafb70f87 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -708,4 +708,4 @@ if (Utils::isNinjaDev()) //ini_set('memory_limit','1024M'); //Auth::loginUsingId(1); } -*/ +*/ \ No newline at end of file diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 12ab7dadcc..439247f337 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -247,7 +247,7 @@ class Utils return "***{$class}*** [{$code}] : {$exception->getFile()} [Line {$exception->getLine()}] => {$exception->getMessage()}"; } - public static function logError($error, $context = 'PHP') + public static function logError($error, $context = 'PHP', $info = false) { if ($error instanceof Exception) { $error = self::getErrorString($error); @@ -271,7 +271,11 @@ class Utils 'count' => Session::get('error_count', 0), ]; - Log::error($error."\n", $data); + if ($info) { + Log::info($error."\n", $data); + } else { + Log::error($error."\n", $data); + } /* Mail::queue('emails.error', ['message'=>$error.' '.json_encode($data)], function($message) diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index c30c9a10d7..7afcc2548c 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -81,7 +81,7 @@ class Mailer $emailError = $exception->getMessage(); } - Utils::logError("Email Error: $emailError"); + //Utils::logError("Email Error: $emailError"); if (isset($data['invitation'])) { $invitation = $data['invitation']; diff --git a/bootstrap/app.php b/bootstrap/app.php index 354e5dd905..71f392315f 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -58,4 +58,9 @@ if (strstr($_SERVER['HTTP_USER_AGENT'], 'PhantomJS') && Utils::isNinjaDev()) { } */ +// Write info messages to a separate file +$app->configureMonologUsing(function($monolog) { + $monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-info.log', Monolog\Logger::INFO, false)); +}); + return $app;