Elgg
Version 3.0
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
engine
classes
Elgg
Logger
ElggLogFormatter.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Elgg\Logger
;
4
5
use
Monolog\Formatter\LineFormatter
;
6
10
class
ElggLogFormatter
extends
LineFormatter {
11
15
public
function
format
(array $record) {
16
17
$context
=
elgg_extract
(
'context'
, $record, []);
18
$exception
=
elgg_extract
(
'exception'
,
$context
);
19
20
if
(
$exception
instanceof \
Throwable
) {
21
$timestamp
= isset(
$exception
->timestamp) ? (int)
$exception
->timestamp : time();
22
23
$dt
= new \DateTime();
24
$dt
->setTimestamp(
$timestamp
);
25
$record[
'datetime'
] =
$dt
;
26
27
$eol = PHP_EOL;
28
$message
=
"Exception at time {$timestamp}:{$eol}{$exception}{$eol}"
;
29
$record[
'message'
] = preg_replace(
'~\R~u'
, $eol,
$message
);
30
31
if
(
$exception
instanceof \
DatabaseException
) {
32
$record[
'context'
][
'sql'
] =
$exception
->getQuery();
33
$record[
'context'
][
'params'
] =
$exception
->getParameters();
34
}
35
}
36
37
return
parent::format($record);
38
}
39
}
$context
$context
Definition:
add.php:8
Elgg\Logger\ElggLogFormatter
Custom log formatter.
Definition:
ElggLogFormatter.php:10
LineFormatter
$message
$message
Definition:
set_maintenance_mode.php:7
$timestamp
$timestamp
Definition:
date.php:33
Elgg\Logger
Definition:
BacktraceProcessor.php:3
DatabaseException
$dt
$dt
Definition:
time.php:69
Elgg\Logger\ElggLogFormatter\format
format(array $record)
{}
Definition:
ElggLogFormatter.php:15
$exception
$exception
Definition:
admin_exception.php:14
elgg_extract
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition:
elgglib.php:1131
Throwable
Generated on Sun Mar 7 2021 00:00:23 for Elgg by
1.8.11