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


PHP CakeLog::stream方法代碼示例

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


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

示例1: testValidKeyName

 /**
  * test config() with valid key name
  *
  * @return void
  */
 public function testValidKeyName()
 {
     CakeLog::config('valid', array('engine' => 'FileLog'));
     $stream = CakeLog::stream('valid');
     $this->assertInstanceOf('FileLog', $stream);
     CakeLog::drop('valid');
 }
開發者ID:carriercomm,項目名稱:professional-inventory-and-billing-system,代碼行數:12,代碼來源:CakeLogTest.php

示例2: setUp

 /**
  * Sets up a mocked logger stream
  *
  * @return void
  **/
 public function setUp()
 {
     parent::setUp();
     $class = $this->getMockClass('BaseLog');
     CakeLog::config('queuetest', array('engine' => $class, 'types' => array('error'), 'scopes' => ['gearman']));
     $this->logger = CakeLog::stream('queuetest');
     Configure::write('Gearman', array());
 }
開發者ID:lorenzo,項目名稱:cakephp-gearman,代碼行數:13,代碼來源:GearmanQueueTest.php

示例3: setUp

 /**
  * Sets up a mocked logger stream
  *
  * @return void
  **/
 public function setUp()
 {
     parent::setUp();
     $class = $this->getMockClass('BaseLog', array('write'), array(), 'SQSBaseLog');
     CakeLog::config('queuetest', array('engine' => $class, 'types' => array('error', 'debug'), 'scopes' => array('sqs')));
     $this->logger = CakeLog::stream('queuetest');
     CakeLog::disable('stderr');
     Configure::write('SQS', array());
 }
開發者ID:dilab,項目名稱:cakephp-sqs,代碼行數:14,代碼來源:SimpleQueueTest.php

示例4: setUp

 /**
  * Sets up a mocked logger stream
  *
  * @return void
  **/
 public function setUp()
 {
     parent::setUp();
     $this->_root = Nodes\Environment::getRoot();
     Nodes\Environment::setRoot('/var/www/test');
     $class = $this->getMockClass('BaseLog');
     CakeLog::config('queuetest', array('engine' => $class, 'types' => array('error')));
     $this->logger = CakeLog::stream('queuetest');
 }
開發者ID:nodesagency,項目名稱:Platform-Common-Plugin,代碼行數:14,代碼來源:GearmanQueueTest.php

示例5: testLog

 public function testLog()
 {
     $stream = CakeLog::stream('error');
     $engine = get_class($stream);
     $config = array_merge($stream->config(), compact('engine'));
     CakeLog::config('error', array_merge($config, array('engine' => 'FileLog', 'path' => TMP . 'tests' . DS)));
     $filepath = TMP . 'tests' . DS . 'error.log';
     if (file_exists($filepath)) {
         unlink($filepath);
     }
     $this->assertTrue($this->Model->log('Test warning 1'));
     $this->assertTrue($this->Model->log(array('Test' => 'warning 2')));
     $result = file($filepath);
     $this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]);
     $this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]);
     $this->assertRegExp('/^\\($/', $result[2]);
     $this->assertRegExp('/\\[Test\\] => warning 2$/', $result[3]);
     $this->assertRegExp('/^\\)$/', $result[4]);
     unlink($filepath);
     $this->assertTrue($this->Model->log('Test warning 1', LOG_WARNING));
     $this->assertTrue($this->Model->log(array('Test' => 'warning 2'), LOG_WARNING));
     $result = file($filepath);
     $this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]);
     $this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Array$/', $result[1]);
     $this->assertRegExp('/^\\($/', $result[2]);
     $this->assertRegExp('/\\[Test\\] => warning 2$/', $result[3]);
     $this->assertRegExp('/^\\)$/', $result[4]);
     unlink($filepath);
     CakeLog::config('error', array_merge($config, array('engine' => 'FileLog', 'path' => TMP . 'tests' . DS, 'scopes' => array('some_scope'))));
     $this->assertTrue($this->Model->log('Test warning 1', LOG_WARNING));
     $this->assertTrue(!file_exists($filepath));
     $this->assertTrue($this->Model->log('Test warning 1', LOG_WARNING, 'some_scope'));
     $result = file($filepath);
     $this->assertRegExp('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]);
     CakeLog::config('error', $config);
 }
開發者ID:gourmet,項目名稱:common,代碼行數:36,代碼來源:CommonAppModelTest.php

示例6: testLogError

 /**
  * test LogError()
  *
  * @return void
  */
 public function testLogError()
 {
     @unlink(LOGS . 'error.log');
     // disable stderr output for this test
     if (CakeLog::stream('stderr')) {
         CakeLog::disable('stderr');
     }
     LogError('Testing LogError() basic function');
     LogError("Testing with\nmulti-line\nstring");
     if (CakeLog::stream('stderr')) {
         CakeLog::enable('stderr');
     }
     $result = file_get_contents(LOGS . 'error.log');
     $this->assertRegExp('/Error: Testing LogError\\(\\) basic function/', $result);
     $this->assertNotRegExp("/Error: Testing with\nmulti-line\nstring/", $result);
     $this->assertRegExp('/Error: Testing with multi-line string/', $result);
 }
開發者ID:pritten,項目名稱:SmartCitizen.me,代碼行數:22,代碼來源:BasicsTest.php

示例7: testProtectedUseLogger

 /**
  * Tests that _useLogger works properly
  *
  * @return void
  */
 public function testProtectedUseLogger()
 {
     CakeLog::drop('stdout');
     CakeLog::drop('stderr');
     $this->Shell->useLogger(true);
     $this->assertNotEmpty(CakeLog::stream('stdout'));
     $this->assertNotEmpty(CakeLog::stream('stderr'));
     $this->Shell->useLogger(false);
     $this->assertFalse(CakeLog::stream('stdout'));
     $this->assertFalse(CakeLog::stream('stderr'));
 }
開發者ID:hupla78,項目名稱:Nadia,代碼行數:16,代碼來源:ShellTest.php

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