• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Log/Formatter/Simple.php

00001 <?php
00024 require_once 'Zend/Log/Formatter/Interface.php';
00025 
00034 class Zend_Log_Formatter_Simple implements Zend_Log_Formatter_Interface
00035 {
00039     protected $_format;
00040 
00041     const DEFAULT_FORMAT = '%timestamp% %priorityName% (%priority%): %message%';
00042 
00049     public function __construct($format = null)
00050     {
00051         if ($format === null) {
00052             $format = self::DEFAULT_FORMAT . PHP_EOL;
00053         }
00054 
00055         if (! is_string($format)) {
00056             require_once 'Zend/Log/Exception.php';
00057             throw new Zend_Log_Exception('Format must be a string');
00058         }
00059 
00060         $this->_format = $format;
00061     }
00062 
00069     public function format($event)
00070     {
00071         $output = $this->_format;
00072         foreach ($event as $name => $value) {
00073 
00074             if ((is_object($value) && !method_exists($value,'__toString'))
00075                 || is_array($value)) {
00076 
00077                 $value = gettype($value);
00078             }
00079 
00080             $output = str_replace("%$name%", $value, $output);
00081         }
00082         return $output;
00083     }
00084 
00085 }

Generated on Thu Apr 19 2012 17:01:17 for openbiz by  doxygen 1.7.2