. */ /** * @package Doctrine * @subpackage Log * @author Konsta Vesterinen * @author Jonathan H. Wage * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org * @since 1.0 * @version $Revision: 3155 $ */ class Doctrine_Log_Formatter_Simple implements Doctrine_Log_Formatter_Interface { /** * @var string */ protected $_format; /** * Class constructor * * @param null|string $format Format specifier for log messages * @throws Doctrine_Log_Exception */ public function __construct($format = null) { if ($format === null) { $format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL; } if (! is_string($format)) { throw new Doctrine_Log_Exception('Format must be a string'); } $this->_format = $format; } /** * Formats data into a single line to be written by the writer. * * @param array $event event data * @return string formatted line to write to the log */ public function format($event) { $output = $this->_format; foreach ($event as $name => $value) { $output = str_replace("%$name%", $value, $output); } return $output; } }