Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432745
ChromePHPFormatter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ChromePHPFormatter.php
View Options
<?php
declare
(
strict_types
=
1
);
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Monolog\Formatter
;
use
Monolog\Logger
;
/**
* Formats a log message according to the ChromePHP array format
*
* @author Christophe Coevoet <stof@notk.org>
*/
class
ChromePHPFormatter
implements
FormatterInterface
{
/**
* Translates Monolog log levels to Wildfire levels.
*
* @var array<int, 'log'|'info'|'warn'|'error'>
*/
private
$logLevels
=
[
Logger
::
DEBUG
=>
'log'
,
Logger
::
INFO
=>
'info'
,
Logger
::
NOTICE
=>
'info'
,
Logger
::
WARNING
=>
'warn'
,
Logger
::
ERROR
=>
'error'
,
Logger
::
CRITICAL
=>
'error'
,
Logger
::
ALERT
=>
'error'
,
Logger
::
EMERGENCY
=>
'error'
,
];
/**
* {@inheritDoc}
*/
public
function
format
(
array
$record
)
{
// Retrieve the line and file if set and remove them from the formatted extra
$backtrace
=
'unknown'
;
if
(
isset
(
$record
[
'extra'
][
'file'
],
$record
[
'extra'
][
'line'
]))
{
$backtrace
=
$record
[
'extra'
][
'file'
].
' : '
.
$record
[
'extra'
][
'line'
];
unset
(
$record
[
'extra'
][
'file'
],
$record
[
'extra'
][
'line'
]);
}
$message
=
[
'message'
=>
$record
[
'message'
]];
if
(
$record
[
'context'
])
{
$message
[
'context'
]
=
$record
[
'context'
];
}
if
(
$record
[
'extra'
])
{
$message
[
'extra'
]
=
$record
[
'extra'
];
}
if
(
count
(
$message
)
===
1
)
{
$message
=
reset
(
$message
);
}
return
[
$record
[
'channel'
],
$message
,
$backtrace
,
$this
->
logLevels
[
$record
[
'level'
]],
];
}
/**
* {@inheritDoc}
*/
public
function
formatBatch
(
array
$records
)
{
$formatted
=
[];
foreach
(
$records
as
$record
)
{
$formatted
[]
=
$this
->
format
(
$record
);
}
return
$formatted
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 22:16 (1 d, 3 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b5/6c/d4ded58ba768648d454463c6b052
Default Alt Text
ChromePHPFormatter.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment