blob: 1e0bd0ed12841ebdb2145bfb2f8a226c633684c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Log\Formatter;
use Piwik\ExceptionHandler;
use Piwik\Log;
/**
* Formats a log message containing an exception object into a textual string.
*/
class ExceptionTextFormatter extends Formatter
{
public function format(array $record, Log $logger)
{
$message = $record['message'];
if ($message instanceof \Exception) {
$record['message'] = sprintf("%s(%d): %s\n%s", $message->getFile(), $message->getLine(), $message->getMessage(),
ExceptionHandler::$debugBacktraceForTests ?: $message->getTraceAsString());
}
return $this->next($record, $logger);
}
}
|