|
@@ -20,8 +20,8 @@
|
|
|
* @version $Id$
|
|
* @version $Id$
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-/** Zend_Log_Formatter_Interface */
|
|
|
|
|
-require_once 'Zend/Log/Formatter/Interface.php';
|
|
|
|
|
|
|
+/** Zend_Log_Formatter_Abstract */
|
|
|
|
|
+require_once 'Zend/Log/Formatter/Abstract.php';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @category Zend
|
|
* @category Zend
|
|
@@ -31,7 +31,7 @@ require_once 'Zend/Log/Formatter/Interface.php';
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
* @version $Id$
|
|
* @version $Id$
|
|
|
*/
|
|
*/
|
|
|
-class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
|
|
|
|
|
|
|
+class Zend_Log_Formatter_Simple extends Zend_Log_Formatter_Abstract
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
* @var string
|
|
* @var string
|
|
@@ -53,7 +53,7 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
|
|
|
$format = self::DEFAULT_FORMAT . PHP_EOL;
|
|
$format = self::DEFAULT_FORMAT . PHP_EOL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (! is_string($format)) {
|
|
|
|
|
|
|
+ if (!is_string($format)) {
|
|
|
require_once 'Zend/Log/Exception.php';
|
|
require_once 'Zend/Log/Exception.php';
|
|
|
throw new Zend_Log_Exception('Format must be a string');
|
|
throw new Zend_Log_Exception('Format must be a string');
|
|
|
}
|
|
}
|
|
@@ -62,6 +62,28 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * Factory for Zend_Log_Formatter_Simple classe
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param array|Zend_Config $options
|
|
|
|
|
+ * @return Zend_Log_Formatter_Simple
|
|
|
|
|
+ */
|
|
|
|
|
+ public static function factory($options)
|
|
|
|
|
+ {
|
|
|
|
|
+ $format = null;
|
|
|
|
|
+ if (null !== $options) {
|
|
|
|
|
+ if ($options instanceof Zend_Config) {
|
|
|
|
|
+ $options = $options->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (array_key_exists('format', $options)) {
|
|
|
|
|
+ $format = $options['format'];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return new self($format);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* Formats data into a single line to be written by the writer.
|
|
* Formats data into a single line to be written by the writer.
|
|
|
*
|
|
*
|
|
|
* @param array $event event data
|
|
* @param array $event event data
|
|
@@ -70,17 +92,17 @@ class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
|
|
|
public function format($event)
|
|
public function format($event)
|
|
|
{
|
|
{
|
|
|
$output = $this->_format;
|
|
$output = $this->_format;
|
|
|
- foreach ($event as $name => $value) {
|
|
|
|
|
|
|
|
|
|
|
|
+ foreach ($event as $name => $value) {
|
|
|
if ((is_object($value) && !method_exists($value,'__toString'))
|
|
if ((is_object($value) && !method_exists($value,'__toString'))
|
|
|
- || is_array($value)) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ || is_array($value)
|
|
|
|
|
+ ) {
|
|
|
$value = gettype($value);
|
|
$value = gettype($value);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$output = str_replace("%$name%", $value, $output);
|
|
$output = str_replace("%$name%", $value, $output);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
return $output;
|
|
return $output;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
|
|
+}
|