58 parent::__construct(
'U.u');
73 if (!isset($record[
'datetime'], $record[
'message'], $record[
'level'])) {
74 throw new \InvalidArgumentException(
'The record should at least contain datetime, message and level keys, '.var_export($record,
true).
' given');
79 ->setTimestamp($record[
'datetime'])
80 ->setShortMessage((
string) $record[
'message'])
81 ->setHost($this->systemName)
82 ->setLevel($this->logLevels[$record[
'level']]);
85 $len = 200 + strlen((
string) $record[
'message']) + strlen($this->systemName);
87 if ($len > self::MAX_LENGTH) {
88 $message->setShortMessage(substr($record[
'message'], 0, self::MAX_LENGTH - 200));
93 if (isset($record[
'channel'])) {
94 $message->setFacility($record[
'channel']);
95 $len += strlen($record[
'channel']);
97 if (isset($record[
'extra'][
'line'])) {
98 $message->setLine($record[
'extra'][
'line']);
100 unset($record[
'extra'][
'line']);
102 if (isset($record[
'extra'][
'file'])) {
103 $message->setFile($record[
'extra'][
'file']);
104 $len += strlen($record[
'extra'][
'file']);
105 unset($record[
'extra'][
'file']);
108 foreach ($record[
'extra'] as
$key => $val) {
109 $val = is_scalar($val) || null === $val ? $val : $this->
toJson($val);
110 $len += strlen($this->extraPrefix .
$key . $val);
111 if ($len > self::MAX_LENGTH) {
112 $message->setAdditional($this->extraPrefix .
$key, substr($val, 0, self::MAX_LENGTH - $len));
115 $message->setAdditional($this->extraPrefix .
$key, $val);
118 foreach ($record[
'context'] as
$key => $val) {
119 $val = is_scalar($val) || null === $val ? $val : $this->
toJson($val);
120 $len += strlen($this->contextPrefix .
$key . $val);
121 if ($len > self::MAX_LENGTH) {
122 $message->setAdditional($this->contextPrefix .
$key, substr($val, 0, self::MAX_LENGTH - $len));
125 $message->setAdditional($this->contextPrefix .
$key, $val);
128 if (null ===
$message->getFile() && isset($record[
'context'][
'exception'][
'file'])) {
129 if (preg_match(
"/^(.+):([0-9]+)$/", $record[
'context'][
'exception'][
'file'], $matches)) {
const NOTICE
Uncommon events.
const DEBUG
Detailed debug information.
const ERROR
Runtime errors.
catch(Exception $e) $message
const WARNING
Exceptional occurrences that are not errors.
const EMERGENCY
Urgent alert.
Create styles array
The data for the language used.
const CRITICAL
Critical conditions.
const ALERT
Action must be taken immediately.
Write to Excel2007 format
const INFO
Interesting events.