26 const SIMPLE_FORMAT =
"[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
68 public function format(array $record)
70 $vars = parent::format($record);
74 foreach ($vars[
'extra'] as $var => $val) {
75 if (
false !== strpos(
$output,
'%extra.'.$var.
'%')) {
76 $output = str_replace(
'%extra.'.$var.
'%', $this->stringify($val),
$output);
77 unset($vars[
'extra'][$var]);
82 foreach ($vars[
'context'] as $var => $val) {
83 if (
false !== strpos(
$output,
'%context.'.$var.
'%')) {
84 $output = str_replace(
'%context.'.$var.
'%', $this->stringify($val),
$output);
85 unset($vars[
'context'][$var]);
90 if (empty($vars[
'context'])) {
91 unset($vars[
'context']);
95 if (empty($vars[
'extra'])) {
96 unset($vars[
'extra']);
101 foreach ($vars as $var => $val) {
102 if (
false !== strpos(
$output,
'%'.$var.
'%')) {
103 $output = str_replace(
'%'.$var.
'%', $this->stringify($val),
$output);
108 if (
false !== strpos(
$output,
'%')) {
109 $output = preg_replace(
'/%(?:extra|context)\..+?%/',
'',
$output);
118 foreach ($records as $record) {
134 throw new \InvalidArgumentException(
'Exception/Throwable expected, got '.gettype($e).
' / '.
Utils::getClass($e));
138 if ($previous = $e->getPrevious()) {
140 $previousText .=
', '.Utils::getClass($previous).
'(code: '.$previous->getCode().
'): '.$previous->getMessage().
' at '.$previous->getFile().
':'.$previous->getLine();
141 }
while ($previous = $previous->getPrevious());
144 $str =
'[object] ('.Utils::getClass($e).
'(code: '.$e->getCode().
'): '.$e->getMessage().
' at '.$e->getFile().
':'.$e->getLine().$previousText.
')';
146 $str .=
"\n[stacktrace]\n".$e->getTraceAsString().
"\n";
155 return var_export(
$data,
true);
158 if (is_scalar(
$data)) {
159 return (
string)
$data;
162 if (version_compare(PHP_VERSION,
'5.4.0',
'>=')) {
166 return str_replace(
'\\/',
'/', @json_encode(
$data));
172 if (0 === strpos($str,
'{')) {
173 return str_replace(array(
'\r',
'\n'), array(
"\r",
"\n"), $str);
179 return str_replace(array(
"\r\n",
"\r",
"\n"),
' ', $str);
catch(Exception $e) $message
while(false !==($line=fgets($in))) if(! $columns) $ignore