本文整理汇总了PHP中CakeLog::config方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeLog::config方法的具体用法?PHP CakeLog::config怎么用?PHP CakeLog::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeLog
的用法示例。
在下文中一共展示了CakeLog::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: 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');
}
示例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: __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));
}
示例5: setUp
public function setUp() {
parent::setUp();
CakeLog::config('debug', array(
'engine' => 'FileLog',
'types' => array('notice', 'info', 'debug'),
'file' => 'debug',
));
CakeLog::config('error', array(
'engine' => 'FileLog',
'types' => array('error', 'warning'),
'file' => 'error',
));
}
示例6: 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);
}
示例7: testLogDepth
/**
* test log() depth
*
* @return void
*/
public function testLogDepth()
{
if (file_exists(LOGS . 'debug.log')) {
unlink(LOGS . 'debug.log');
}
CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS));
$val = array('test' => array('key' => 'val'));
Debugger::log($val, LOG_DEBUG, 0);
$result = file_get_contents(LOGS . 'debug.log');
$this->assertContains('DebuggerTest::testLog', $result);
$this->assertNotContains("/'val'/", $result);
unlink(LOGS . 'debug.log');
}
示例8: array
/**
* Configure the cache handlers that CakePHP will use for internal
* metadata like class maps, and model schema.
*
* By default File is used, but for improved performance you should use APC.
*
* Note: 'default' and other application caches should be configured in app/Config/bootstrap.php.
* Please check the comments in bootstrap.php for more info on the cache engines available
* and their settings.
*/
$engine = 'File';
// In development mode, caches should expire quickly.
$duration = '+999 days';
if (Configure::read('debug') > 0) {
$duration = '+10 seconds';
}
// Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts.
$prefix = 'site_';
App::uses('CakeLog', 'Log');
CakeLog::config('default', array('engine' => 'FileLog'));
/**
* Configure the cache used for general framework caching. Path information,
* object listings, and translation cache files are stored with this configuration.
*/
Cache::config('_cake_core_', array('engine' => $engine, 'prefix' => $prefix . 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => $engine === 'File', 'duration' => $duration));
/**
* Configure the cache for model and datasource caches. This cache configuration
* is used to store schema descriptions, and table listings in connections.
*/
Cache::config('_cake_model_', array('engine' => $engine, 'prefix' => $prefix . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => $engine === 'File', 'duration' => $duration));
Cache::config('default', array('engine' => $engine, 'serialize' => $engine === 'File', 'duration' => 31 * DAY));
示例9: array
* Configure::write('I18n.preferApp', true);
*/
/**
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
*
* - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins
* - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers
*
* Feel free to remove or add filters as you see fit for your application. A few examples:
*
* Configure::write('Dispatcher.filters', array(
* 'MyCacheFilter', // will use MyCacheFilter class from the Routing/Filter package in your app.
* 'MyCacheFilter' => array('prefix' => 'my_cache_'), // will use MyCacheFilter class from the Routing/Filter package in your app with settings array.
* 'MyPlugin.MyFilter', // will use MyFilter class from the Routing/Filter package in MyPlugin plugin.
* array('callable' => $aFunction, 'on' => 'before', 'priority' => 9), // A valid PHP callback type to be called on beforeDispatch
* array('callable' => $anotherMethod, 'on' => 'after'), // A valid PHP callback type to be called on afterDispatch
*
* ));
*/
Configure::write('Dispatcher.filters', array('AssetDispatcher', 'CacheDispatcher'));
/**
* Configures default file logging options
*/
App::uses('CakeLog', 'Log');
CakeLog::config('default', array('engine' => 'File'));
CakeLog::config('debug', array('engine' => 'File', 'types' => array('notice', 'info', 'debug'), 'file' => 'debug'));
CakeLog::config('error', array('engine' => 'File', 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), 'file' => 'error'));
CakeLog::config('payment', array('engine' => 'FileLog', 'types' => array('info', 'error', 'warning'), 'scopes' => array('payment'), 'file' => 'payment'));
CakePlugin::load('DebugKit');
CakePlugin::load('Upload');
CakePlugin::load('BoostCake');
示例10: tearDown
/**
* Teardown
*/
public function tearDown()
{
CakeLog::config('default', array('engine' => 'FileLog'));
parent::tearDown();
}
示例11: shepherds
public function shepherds()
{
CakeLog::config('sensor', array('engine' => 'FileLog', 'types' => array('warning', 'error', 'info'), 'scopes' => array('sensors'), 'file' => 'sensors.log'));
$this->layout = 'ajax';
if ($this->request->is('put')) {
$this->logMe('PUT /pswn/shepherds');
$return = '{"action":"updated"}';
} else {
if ($this->request->is('get')) {
$this->logMe('GET /pswn/shepherds');
$str = '';
$return = '{"timeslice":"1/6","beacon_time":23,"bcc":120}';
}
}
$this->response->type('json');
$this->set('jsonResponse', $return);
}
示例12: array
'file' => 'debug',
));*/
/*CakeLog::config('error', array(
'engine' => 'File',
'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
'file' => 'error',
));*/
CakeLog::config('debug', Configure::read(APP_NAME . '.logging.debug'));
CakeLog::config('error', Configure::read(APP_NAME . '.logging.error'));
/*
* Load plugins
*/
//CakePlugin::load('OrcaTools', array('bootstrap' => true));
CakePlugin::load('OrcaAppSetup');
CakePlugin::load('FakeSeeder');
CakePlugin::load('DebugKit');
CakePlugin::load('MultiColumnUniqueness');
//CakePlugin::load('ValidForeignKeyBehavior');
CakePlugin::load('Migrations');
CakePlugin::load('DatabaseLog');
CakePlugin::load('ClearCache');
// Load those plugins only when in debug mode
if (Configure::read('debug')) {
CakePlugin::load('TestDataValidation');
}
/**
* Setup additional logging
*/
if (Configure::check(APP_NAME . '.logging.database')) {
CakeLog::config('default', Configure::read(APP_NAME . '.logging.database'));
}
示例13: testSendWithLogAndScope
/**
* testSendWithLogAndScope method
*
* @return void
*/
public function testSendWithLogAndScope()
{
CakeLog::config('email', array('engine' => 'File', 'path' => TMP, 'types' => array('cake_test_emails'), 'scopes' => array('email')));
CakeLog::drop('default');
$this->CakeEmail->transport('Debug');
$this->CakeEmail->to('me@cakephp.org');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->subject('My title');
$this->CakeEmail->config(array('log' => array('level' => 'cake_test_emails', 'scope' => 'email')));
$result = $this->CakeEmail->send("Logging This");
App::uses('File', 'Utility');
$File = new File(TMP . 'cake_test_emails.log');
$log = $File->read();
$this->assertTrue(strpos($log, $result['headers']) !== FALSE);
$this->assertTrue(strpos($log, $result['message']) !== FALSE);
$File->delete();
CakeLog::drop('email');
}
示例14:
CakePlugin::load('Jcamp');
/**
* To prefer app translation over plugin translation, you can set
*
* Configure::write('I18n.preferApp', true);
*/
/**
* You can attach event listeners to the request lifecycle as Dispatcher Filter. By default CakePHP bundles two filters:
*
* - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins
* - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers
*
* Feel free to remove or add filters as you see fit for your application. A few examples:
*
* Configure::write('Dispatcher.filters', array(
* 'MyCacheFilter', // will use MyCacheFilter class from the Routing/Filter package in your app.
* 'MyCacheFilter' => array('prefix' => 'my_cache_'), // will use MyCacheFilter class from the Routing/Filter package in your app with settings array.
* 'MyPlugin.MyFilter', // will use MyFilter class from the Routing/Filter package in MyPlugin plugin.
* array('callable' => $aFunction, 'on' => 'before', 'priority' => 9), // A valid PHP callback type to be called on beforeDispatch
* array('callable' => $anotherMethod, 'on' => 'after'), // A valid PHP callback type to be called on afterDispatch
*
* ));
*/
Configure::write('Dispatcher.filters', ['AssetDispatcher', 'CacheDispatcher']);
/**
* Configures default file logging options
*/
App::uses('CakeLog', 'Log');
CakeLog::config('debug', ['engine' => 'File', 'types' => ['notice', 'info', 'debug'], 'file' => 'debug']);
CakeLog::config('error', ['engine' => 'File', 'types' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error']);
示例15: __construct
/**
* Constructs this Shell instance.
*
* @param ConsoleOutput $stdout
* A ConsoleOutput object for stdout.
* @param ConsoleOutput $stderr
* A ConsoleOutput object for stderr.
* @param ConsoleInput $stdin
* A ConsoleInput object for stdin.
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell
*/
public function __construct($stdout = null, $stderr = null, $stdin = null)
{
if ($this->name == null) {
$this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this)));
}
$this->Tasks = new TaskCollection($this);
$this->stdout = $stdout;
$this->stderr = $stderr;
$this->stdin = $stdin;
if ($this->stdout == null) {
$this->stdout = new ConsoleOutput('php://stdout');
}
CakeLog::config('stdout', array('engine' => 'ConsoleLog', 'types' => array('notice', 'info'), 'stream' => $this->stdout));
if ($this->stderr == null) {
$this->stderr = new ConsoleOutput('php://stderr');
}
CakeLog::config('stderr', array('engine' => 'ConsoleLog', 'types' => array('emergency', 'alert', 'critical', 'error', 'warning', 'debug'), 'stream' => $this->stderr));
if ($this->stdin == null) {
$this->stdin = new ConsoleInput('php://stdin');
}
$parent = get_parent_class($this);
if ($this->tasks !== null && $this->tasks !== false) {
$this->_mergeVars(array('tasks'), $parent, true);
}
if ($this->uses !== null && $this->uses !== false) {
$this->_mergeVars(array('uses'), $parent, false);
}
}