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