本文整理汇总了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');
}
示例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());
}
示例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());
}
示例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');
}
示例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);
}
示例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);
}
示例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'));
}
示例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);
}
}