mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Log 404s to separate file
This commit is contained in:
parent
62c616b0ac
commit
6ec0288462
@ -59,13 +59,17 @@ class Handler extends ExceptionHandler
|
|||||||
if (Utils::isNinja() && strpos(request()->url(), '/logo/') !== false) {
|
if (Utils::isNinja() && strpos(request()->url(), '/logo/') !== false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Log 404s to a separate file
|
||||||
|
$errorStr = date('Y-m-d h:i:s') . ' ' . request()->url() . "\n" . json_encode(Utils::prepareErrorData('PHP')) . "\n\n";
|
||||||
|
@file_put_contents(storage_path('logs/not_found.log'), $errorStr, FILE_APPEND);
|
||||||
|
return false;
|
||||||
} elseif ($e instanceof HttpResponseException) {
|
} elseif ($e instanceof HttpResponseException) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! Utils::isTravis()) {
|
if (! Utils::isTravis()) {
|
||||||
Utils::logError(Utils::getErrorString($e));
|
Utils::logError(Utils::getErrorString($e));
|
||||||
$stacktrace = date('Y-m-d h:i:s') . ' ' . $e->getTraceAsString();
|
$stacktrace = date('Y-m-d h:i:s') . ' ' . $e->getTraceAsString() . "\n\n";
|
||||||
@file_put_contents(storage_path('logs/stacktrace.log'), $stacktrace, FILE_APPEND);
|
@file_put_contents(storage_path('logs/stacktrace.log'), $stacktrace, FILE_APPEND);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -382,7 +382,18 @@ class Utils
|
|||||||
return 'logged';
|
return 'logged';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = static::prepareErrorData($context);
|
||||||
|
|
||||||
|
if ($info) {
|
||||||
|
Log::info($error."\n", $data);
|
||||||
|
} else {
|
||||||
|
Log::error($error."\n", $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function prepareErrorData($context)
|
||||||
|
{
|
||||||
|
return [
|
||||||
'context' => $context,
|
'context' => $context,
|
||||||
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
||||||
'account_id' => Auth::check() ? Auth::user()->account_id : 0,
|
'account_id' => Auth::check() ? Auth::user()->account_id : 0,
|
||||||
@ -397,19 +408,6 @@ class Utils
|
|||||||
'is_api' => session('token_id') ? 'yes' : 'no',
|
'is_api' => session('token_id') ? 'yes' : 'no',
|
||||||
'db_server' => config('database.default'),
|
'db_server' => config('database.default'),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($info) {
|
|
||||||
Log::info($error."\n", $data);
|
|
||||||
} else {
|
|
||||||
Log::error($error."\n", $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Mail::queue('emails.error', ['message'=>$error.' '.json_encode($data)], function($message)
|
|
||||||
{
|
|
||||||
$message->to($email)->subject($subject);
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseFloat($value)
|
public static function parseFloat($value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user