Advertisement
Guest User

unzend.com_339

a guest
Jan 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.57 KB | None | 0 0
  1. <?php
  2. // ionCube version 9 Decoder unzend.com - Email: unzend@gmail.com
  3. // http://www.unzend.com
  4. /**
  5.  * CLogRouter class file.
  6.  *
  7.  * @author Qiang Xue <qiang.xue@gmail.com>
  8.  * @link http://www.yiiframework.com/
  9.  * @copyright 2008-2013 Yii Software LLC
  10.  * @license http://www.yiiframework.com/license/
  11.  */
  12.  
  13. /**
  14.  * CLogRouter manages log routes that record log messages in different media.
  15.  *
  16.  * For example, a file log route {@link CFileLogRoute} records log messages
  17.  * in log files. An email log route {@link CEmailLogRoute} sends log messages
  18.  * to specific email addresses. See {@link CLogRoute} for more details about
  19.  * different log routes.
  20.  *
  21.  * Log routes may be configured in application configuration like following:
  22.  * <pre>
  23.  * array(
  24.  *     'preload'=>array('log'), // preload log component when app starts
  25.  *     'components'=>array(
  26.  *         'log'=>array(
  27.  *             'class'=>'CLogRouter',
  28.  *             'routes'=>array(
  29.  *                 array(
  30.  *                     'class'=>'CFileLogRoute',
  31.  *                     'levels'=>'trace, info',
  32.  *                     'categories'=>'system.*',
  33.  *                 ),
  34.  *                 array(
  35.  *                     'class'=>'CEmailLogRoute',
  36.  *                     'levels'=>'error, warning',
  37.  *                     'emails'=>array('admin@example.com'),
  38.  *                 ),
  39.  *             ),
  40.  *         ),
  41.  *     ),
  42.  * )
  43.  * </pre>
  44.  *
  45.  * You can specify multiple routes with different filtering conditions and different
  46.  * targets, even if the routes are of the same type.
  47.  *
  48.  * @property array $routes The currently initialized routes.
  49.  *
  50.  * @author Qiang Xue <qiang.xue@gmail.com>
  51.  * @package system.logging
  52.  * @since 1.0
  53.  */
  54. class CLogRouter extends CApplicationComponent
  55. {
  56.     private $_routes=array();
  57.  
  58.     /**
  59.      * Initializes this application component.
  60.      * This method is required by the IApplicationComponent interface.
  61.      */
  62.     public function init()
  63.     {
  64.         parent::init();
  65.         foreach($this->_routes as $name=>$route)
  66.         {
  67.             $route=Yii::createComponent($route);
  68.             $route->init();
  69.             $this->_routes[$name]=$route;
  70.         }
  71.         Yii::getLogger()->attachEventHandler('onFlush',array($this,'collectLogs'));
  72.         Yii::app()->attachEventHandler('onEndRequest',array($this,'processLogs'));
  73.     }
  74.  
  75.     /**
  76.      * @return array the currently initialized routes
  77.      */
  78.     public function getRoutes()
  79.     {
  80.         return new CMap($this->_routes);
  81.     }
  82.  
  83.     /**
  84.      * @param array $config list of route configurations. Each array element represents
  85.      * the configuration for a single route and has the following array structure:
  86.      * <ul>
  87.      * <li>class: specifies the class name or alias for the route class.</li>
  88.      * <li>name-value pairs: configure the initial property values of the route.</li>
  89.      * </ul>
  90.      */
  91.     public function setRoutes($config)
  92.     {
  93.         foreach($config as $name=>$route)
  94.             $this->_routes[$name]=$route;
  95.     }
  96.  
  97.     /**
  98.      * Collects log messages from a logger.
  99.      * This method is an event handler to the {@link CLogger::onFlush} event.
  100.      * @param CEvent $event event parameter
  101.      */
  102.     public function collectLogs($event)
  103.     {
  104.         $logger=Yii::getLogger();
  105.         $dumpLogs=isset($event->params['dumpLogs']) && $event->params['dumpLogs'];
  106.         foreach($this->_routes as $route)
  107.         {
  108.             if($route->enabled)
  109.                 $route->collectLogs($logger,$dumpLogs);
  110.         }
  111.     }
  112.  
  113.     /**
  114.      * Collects and processes log messages from a logger.
  115.      * This method is an event handler to the {@link CApplication::onEndRequest} event.
  116.      * @param CEvent $event event parameter
  117.      * @since 1.1.0
  118.      */
  119.     public function processLogs($event)
  120.     {
  121.         $logger=Yii::getLogger();
  122.         foreach($this->_routes as $route)
  123.         {
  124.             if($route->enabled)
  125.                 $route->collectLogs($logger,true);
  126.         }
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement