コード例 #1
0
ファイル: LogPanel.php プロジェクト: gjcamacho/blog_test
 /**
  * Constructor - sets up the log listener.
  *
  * @return \LogPanel
  */
 public function __construct()
 {
     parent::__construct();
     $existing = CakeLog::configured();
     if (empty($existing)) {
         CakeLog::config('default', array('engine' => 'FileLog'));
     }
     CakeLog::config('debug_kit_log_panel', array('engine' => 'DebugKit.DebugKitLog', 'panel' => $this));
 }
コード例 #2
0
ファイル: LogsController.php プロジェクト: johnulist/admin-1
 /**
  * Parse and read syslogs.
  *
  * @param string $type
  * @throws NotFoundException
  * @throws BadRequestException
  */
 public function read($type = 'debug')
 {
     $path = TMP . 'logs/' . $type . '.log';
     $logs = array();
     $exceptions = array();
     $message = null;
     if (!in_array($type, CakeLog::configured())) {
         throw new NotFoundException(__d('admin', '%s Log Not Found', Inflector::humanize($type)));
     }
     if (file_exists($path)) {
         if (filesize($path) > 2097152) {
             throw new BadRequestException(__d('admin', 'Can not read %s as it exceeds 2MB', basename($path)));
         }
         if ($file = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) {
             $log = array();
             foreach ($file as $line) {
                 // Exception message
                 if (preg_match('/^([0-9\\-:\\s]+)\\s([a-z]+:)\\s(?:\\[([a-z]+)\\])?\\s?(.*?)$/i', $line, $matches)) {
                     $exception = $matches[3];
                     // Save the previous log
                     if ($log) {
                         $key = md5($log['url'] . $log['message']);
                         if (isset($logs[$key])) {
                             $logs[$key]['count']++;
                         } else {
                             $logs[$key] = $log;
                         }
                     }
                     // Start a new log
                     $log = array('line' => $line, 'exception' => $exception, 'message' => $matches[4], 'stack' => array(), 'count' => 1, 'date' => $matches[1], 'url' => null);
                     if ($exception) {
                         $exceptions[$exception][] = $matches[1];
                     }
                     // Request URL
                 } else {
                     if (preg_match('/^Request URL: (.*?)$/i', $line, $matches)) {
                         $log['url'] = $matches[1];
                         // Stack trace
                     } else {
                         if ($line[0] === '#') {
                             $log['stack'][] = $line . PHP_EOL;
                         }
                     }
                 }
             }
         }
         // Sort by count
         usort($logs, function ($a, $b) {
             return $b['count'] - $a['count'];
         });
     }
     $this->set('type', $type);
     $this->set('logs', $logs);
     $this->set('exceptions', $exceptions);
 }
コード例 #3
0
ファイル: LogPanelTest.php プロジェクト: huanjian/mythesis
 /**
  * Test that logging configs are created.
  *
  * @return void
  */
 public function testConstructor()
 {
     $result = CakeLog::configured();
     $this->assertContains('debug_kit_log_panel', $result);
     $this->assertTrue(count($result) > 1, 'Default loggers were not added.');
 }
コード例 #4
0
	/**
	 * explict tests for drop()
	 *
	 * @return void
	 **/
	function testDrop() {
		CakeLog::config('file', array(
			'engine' => 'FileLog',
			'path' => LOGS
		));
		$result = CakeLog::configured();
		$this->assertEqual($result, array('file'));

		CakeLog::drop('file');
		$result = CakeLog::configured();
		$this->assertEqual($result, array());
	}
コード例 #5
0
ファイル: Shell.php プロジェクト: hodrigohamalho/cakephp-ex
 /**
  * Checks if the given logger is configured
  * 
  * @param string $logger The name of the logger to check 
  * @return bool
  */
 protected function _loggerIsConfigured($logger)
 {
     $configured = CakeLog::configured();
     return in_array($logger, $configured);
 }
コード例 #6
0
/**
 * test that creating the log panel creates the default file logger if none
 * are configured.  This stops DebugKit from mucking with the default auto-magic log config
 *
 * @return void
 */
	public function testLogPanelConstructCreatingDefaultLogConfiguration() {
		$this->_loadController();

		CakeLog::drop('default');
		CakeLog::drop('debug_kit_log_panel');

		$panel = new LogPanel(array());
		$configured = CakeLog::configured();

		$this->assertTrue(in_array('default', $configured));
		$this->assertTrue(in_array('debug_kit_log_panel', $configured));
	}
コード例 #7
0
ファイル: CakeLogTest.php プロジェクト: yuuicchan0912/sample1
 /**
  * explicit tests for drop()
  *
  * @return void
  */
 public function testDrop()
 {
     CakeLog::config('file', array('engine' => 'File', 'path' => LOGS));
     $result = CakeLog::configured();
     $this->assertEquals(array('file'), $result);
     CakeLog::drop('file');
     $result = CakeLog::configured();
     $this->assertSame(array(), $result);
 }
コード例 #8
0
ファイル: toolbar.php プロジェクト: ambagasdowa/kml
 /**
  * Constructor - sets up the log listener.
  *
  * @return void
  */
 function __construct($settings)
 {
     parent::__construct();
     if (!class_exists('CakeLog')) {
         App::import('Core', 'CakeLog');
     }
     $existing = CakeLog::configured();
     if (empty($existing)) {
         CakeLog::config('default', array('engine' => 'FileLog'));
     }
     CakeLog::config('debug_kit_log_panel', array('engine' => 'DebugKitLogListener', 'panel' => $this));
 }
コード例 #9
0
ファイル: AppFastFixture.php プロジェクト: beckye67/Icing
 /**
  * Restore original scopes on all loggers
  */
 public function _restoresForSetup()
 {
     foreach (CakeLog::configured() as $name) {
         $logger = CakeLog::stream($name);
         if (!method_exists($logger, 'config')) {
             continue;
         }
         $config = $logger->config();
         if (!array_key_exists('scopes_backup', $config)) {
             continue;
         }
         $config['scopes'] = $config['scopes_backup'];
         unset($config['scopes_backup']);
         $logger->config($config);
     }
 }