當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CakeLog::configured方法代碼示例

本文整理匯總了PHP中CakeLog::configured方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeLog::configured方法的具體用法?PHP CakeLog::configured怎麽用?PHP CakeLog::configured使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CakeLog的用法示例。


在下文中一共展示了CakeLog::configured方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * 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));
 }
開發者ID:gjcamacho,項目名稱:blog_test,代碼行數:14,代碼來源:LogPanel.php

示例2: read

 /**
  * 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);
 }
開發者ID:johnulist,項目名稱:admin-1,代碼行數:62,代碼來源:LogsController.php

示例3: testConstructor

 /**
  * 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.');
 }
開發者ID:huanjian,項目名稱:mythesis,代碼行數:11,代碼來源:LogPanelTest.php

示例4: testDrop

	/**
	 * 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());
	}
開發者ID:ralmeida,項目名稱:FoundFree.org,代碼行數:17,代碼來源:cake_log.test.php

示例5: _loggerIsConfigured

 /**
  * 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);
 }
開發者ID:hodrigohamalho,項目名稱:cakephp-ex,代碼行數:11,代碼來源:Shell.php

示例6: testLogPanelConstructCreatingDefaultLogConfiguration

/**
 * 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));
	}
開發者ID:neterslandreau,項目名稱:tubones,代碼行數:18,代碼來源:ToolbarComponentTest.php

示例7: testDrop

 /**
  * 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);
 }
開發者ID:yuuicchan0912,項目名稱:sample1,代碼行數:14,代碼來源:CakeLogTest.php

示例8: __construct

 /**
  * 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));
 }
開發者ID:ambagasdowa,項目名稱:kml,代碼行數:17,代碼來源:toolbar.php

示例9: _restoresForSetup

 /**
  * 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);
     }
 }
開發者ID:beckye67,項目名稱:Icing,代碼行數:19,代碼來源:AppFastFixture.php


注:本文中的CakeLog::configured方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。