Plop
A simple logging library for PHP
|
A class that provides basic formatting for log records. More...
Public Member Functions | |
__construct ($format=self::DEFAULT_FORMAT, $dateFormat=self::DEFAULT_DATE_FORMAT, $timezone=null, $pythonLike=false,\Plop\InterpolatorInterface $interpolator=null) | |
format (\Plop\RecordInterface $record) | |
getDateFormat () | |
getFormat () | |
getInterpolator () | |
getPythonLike () | |
getTimezone () | |
setDateFormat ($dateFormat) | |
setFormat ($format) | |
setInterpolator (\Plop\InterpolatorInterface $interpolator) | |
setPythonLike ($pythonLike) | |
setTimezone (\DateTimeZone $timezone=null) | |
Public Attributes | |
const | DEFAULT_DATE_FORMAT = "Y-m-d H:i:s,u" |
Default format for dates. | |
const | DEFAULT_FORMAT = '%(message)s' |
Default format for log messages. | |
Protected Member Functions | |
formatException (\Exception $exception) | |
formatTime (\Plop\RecordInterface $record, $dateFormat=self::DEFAULT_DATE_FORMAT) | |
Protected Attributes | |
$dateFormat | |
Format to use for dates/times. | |
$format | |
General format for log records. | |
$interpolator | |
Object to use for interpolation in the final log message. | |
$pythonLike | |
Whether formatException() generates Python-like traces. | |
$timezone | |
Timezone to use to represent dates/times. | |
A class that provides basic formatting for log records.
Definition at line 28 of file Formatter.php.
Plop\Formatter::__construct | ( | $format = self::DEFAULT_FORMAT , |
|
$dateFormat = self::DEFAULT_DATE_FORMAT , |
|||
$timezone = null , |
|||
$pythonLike = false , |
|||
\Plop\InterpolatorInterface | $interpolator = null |
||
) |
Construct a new formatter.
string | $format | (optional) The format specification for log records, which may contain special formatting-sequences. Defaults to the value of the Plop::Formatter::DEFAULT_FORMAT constant. |
string | $dateFormat | (optional) The format specification to use to format dates. The default is to use the value of the Plop::Formatter::DEFAULT_DATE_FORMAT constant. |
DateTimeZone | string | $timezone | (optional) Timezone to use when formatting dates/times. This must be a valid timezone (see http://php.net/timezones.php). Defaults to using the default timezone, as returned by date_default_timezone_get(). |
bool | $pythonLike | (optional) Whether exceptions should be formatted to resemble Python stack traces (true) or if they should keep their original PHP format (false). Defaults to false (display PHP stack traces). |
Plop::InterpolatorInterface | $interpolator | (optional) An object to use for message interpolation. The default is to create a new Plop::Interpolator::Percent instance. Hence, percent-style interpolation is available by default (see Plop::Interpolator::Percent::interpolate() for more information on percent-style interpolation). |
Definition at line 93 of file Formatter.php.
Plop\Formatter::format | ( | \Plop\RecordInterface | $record | ) |
Implements Plop\FormatterInterface.
Definition at line 203 of file Formatter.php.
|
protected |
Format an exception.
::Exception | $exception | The exception to format. |
string | The full trace of the exception, with proper formatting or false if the current PHP settings prevent errors from being displayed. |
Definition at line 265 of file Formatter.php.
|
protected |
Format the creation date of a log record.
Plop::RecordInterface | $record | The log record whose creation date will be formatted. |
string | $dateFormat | (optional) The format to apply. By default, Plop::Formatter::DEFAULT_DATE_FORMAT is used. |
Definition at line 243 of file Formatter.php.
Plop\Formatter::getDateFormat | ( | ) |
Return the format used to render dates.
string | The format used to render dates. |
Implements Plop\FormatterInterface.
Definition at line 131 of file Formatter.php.
Plop\Formatter::getFormat | ( | ) |
Return the general format used to render records.
string | The format used to render records. |
Implements Plop\FormatterInterface.
Definition at line 118 of file Formatter.php.
Plop\Formatter::getPythonLike | ( | ) |
Return whether exceptions are rendered like Python stack traces or not.
bool | true if the exceptions will look like Python stack traces or false if they will look like regular PHP stack traces. |
Implements Plop\FormatterInterface.
Definition at line 165 of file Formatter.php.
Plop\Formatter::getTimezone | ( | ) |
Return the timezone object used to format dates/times.
DateTimeZone | Timezone object used to format dates/times. |
null | Returned when no particular timezone is used to format dates/times (ie. the local timezone is used). |
Implements Plop\FormatterInterface.
Definition at line 144 of file Formatter.php.
Plop\Formatter::setDateFormat | ( | $dateFormat | ) |
Implements Plop\FormatterInterface.
Definition at line 137 of file Formatter.php.
Plop\Formatter::setFormat | ( | $format | ) |
Implements Plop\FormatterInterface.
Definition at line 124 of file Formatter.php.
Plop\Formatter::setPythonLike | ( | $pythonLike | ) |
Set the format used to render exceptions.
bool | $pythonLike | If this is true, exception stack traces will be rendered using a format close to the one Python uses. Otherwise, the original (PHP) format is kept. |
Plop::FormatterInterface | The formatter instance (ie. $this). |
Implements Plop\FormatterInterface.
Definition at line 182 of file Formatter.php.
Plop\Formatter::setTimezone | ( | \DateTimeZone | $timezone = null | ) |
Implements Plop\FormatterInterface.
Definition at line 150 of file Formatter.php.