mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 14:16:42 +02:00
Allow including stack traces in line formatter, fixes #466
This commit is contained in:
@@ -28,6 +28,7 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
protected $format;
|
protected $format;
|
||||||
protected $allowInlineLineBreaks;
|
protected $allowInlineLineBreaks;
|
||||||
protected $ignoreEmptyContextAndExtra;
|
protected $ignoreEmptyContextAndExtra;
|
||||||
|
protected $includeStacktraces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $format The format of the message
|
* @param string $format The format of the message
|
||||||
@@ -43,6 +44,24 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
parent::__construct($dateFormat);
|
parent::__construct($dateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeStacktraces($include = true)
|
||||||
|
{
|
||||||
|
$this->includeStacktraces = $include;
|
||||||
|
if ($this->includeStacktraces) {
|
||||||
|
$this->allowInlineLineBreaks = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function allowInlineLineBreaks($allow = true)
|
||||||
|
{
|
||||||
|
$this->allowInlineLineBreaks = $allow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ignoreEmptyContextAndExtra($ignore = true)
|
||||||
|
{
|
||||||
|
$this->ignoreEmptyContextAndExtra = $ignore;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +118,12 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
} while ($previous = $previous->getPrevious());
|
} while ($previous = $previous->getPrevious());
|
||||||
}
|
}
|
||||||
|
|
||||||
return '[object] ('.get_class($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
|
$str = '[object] ('.get_class($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
|
||||||
|
if ($this->includeStacktraces) {
|
||||||
|
$str .= "\n[stacktrace]\n".$e->getTraceAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function convertToString($data)
|
protected function convertToString($data)
|
||||||
|
Reference in New Issue
Block a user