mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 14:33:49 +01:00
LSlog: fix computing exception context
This commit is contained in:
parent
ef1b4a74e2
commit
22a5be4ddd
1 changed files with 29 additions and 18 deletions
|
@ -401,13 +401,12 @@ class LSlog {
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
public static function exception($exception, $prefix=null, $fatal=true, $logger=null) {
|
public static function exception($exception, $prefix=null, $fatal=true, $logger=null) {
|
||||||
$message =
|
$message = sprintf("%s:\n", $prefix ? $prefix : "An exception occured");
|
||||||
($prefix?"$prefix :\n":"An exception occured :\n").
|
|
||||||
implode(
|
// Add backtrace
|
||||||
"\n",
|
// Note: reverse the backtrace lines to get the entrypoint as first and remove useless first
|
||||||
array_map(
|
// "{main}" line.
|
||||||
function($line) { return " $line"; },
|
$lines = array_slice(
|
||||||
array_slice(
|
|
||||||
array_reverse(
|
array_reverse(
|
||||||
explode(
|
explode(
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -416,9 +415,21 @@ class LSlog {
|
||||||
1
|
1
|
||||||
),
|
),
|
||||||
1
|
1
|
||||||
)
|
);
|
||||||
)
|
foreach($lines as $idx => $line)
|
||||||
)."\n => ". $exception->getMessage();
|
$message .= sprintf(
|
||||||
|
" #%d %s\n",
|
||||||
|
$idx + 1,
|
||||||
|
substr($line, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add exception details
|
||||||
|
$message .= sprintf(
|
||||||
|
" #0 %s(%s) :\n => %s",
|
||||||
|
$exception->getFile(),
|
||||||
|
$exception->getLine(),
|
||||||
|
$exception->getMessage()
|
||||||
|
);
|
||||||
self :: logging(($fatal?'FATAL':'ERROR'), $message, $logger, true);
|
self :: logging(($fatal?'FATAL':'ERROR'), $message, $logger, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue