本文整理汇总了PHP中Cake\Log\Log::engine方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::engine方法的具体用法?PHP Log::engine怎么用?PHP Log::engine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Log\Log
的用法示例。
在下文中一共展示了Log::engine方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* Override main() to handle action
* Starts a Queuesadilla worker
*
* @return void
*/
public function main()
{
$logger = Log::engine($this->getLoggerName('stdout'));
$engine = $this->getEngine($logger);
$worker = $this->getWorker($engine, $logger);
$worker->work();
}
示例2: summary
/**
* Get the summary data.
*
* @return string
*/
public function summary()
{
$logger = Log::engine('debug_kit_log_panel');
if (!$logger) {
return 0;
}
return $logger->count();
}
示例3: main
/**
* Override main() to handle action
* Starts a Queuesadilla worker
*
* @return void
*/
public function main()
{
$engine = $this->params['engine'];
$worker = $this->params['worker'];
$EngineClass = "josegonzalez\\Queuesadilla\\Engine\\" . $engine . 'Engine';
$WorkerClass = "josegonzalez\\Queuesadilla\\Worker\\" . $worker . "Worker";
$config = $this->getEngineConfig();
$loggerName = $this->getLoggerName();
$logger = Log::engine($loggerName);
$engine = new $EngineClass($logger, $config);
$worker = new $WorkerClass($engine, $logger);
$worker->work();
}
示例4: _create
/**
* Create the queue engine instance.
*
* Part of the template method for Cake\Core\ObjectRegistry::load()
*
* @param string|\josegonzalez\Queuesadilla\Engine\EngineInterface $class The classname or object to make.
* @param string $alias The alias of the object.
* @param array $settings An array of settings to use for the queue engine.
* @return \josegonzalez\Queuesadilla\Engine\EngineInterface The constructed queue engine class.
* @throws \RuntimeException when an object doesn't implement the correct interface.
*/
protected function _create($class, $alias, $settings)
{
if (is_callable($class)) {
$class = $class($alias);
}
if (is_object($class)) {
$instance = $class;
}
if (!isset($instance)) {
$key = PHP_SAPI === 'cli' ? 'stdout' : 'default';
$logger = Hash::get($settings, 'logger', $key);
if (!$logger instanceof LoggerInterface) {
$logger = Log::engine($logger);
}
$instance = new $class($logger, $settings);
}
if ($instance instanceof EngineInterface) {
return $instance;
}
throw new RuntimeException('Queue Engines must implement josegonzalez\\Queuesadilla\\Engine\\EngineInterface.');
}
示例5: testCreateLoggerWithCallable
/**
* Tests using a callable for creating a Log engine
*
* @return void
*/
public function testCreateLoggerWithCallable()
{
$instance = new FileLog();
Log::config('default', function () use($instance) {
return $instance;
});
$this->assertSame($instance, Log::engine('default'));
}
示例6: testSetLoggersVerbose
/**
* Tests that setLoggers works properly with verbose
*
* @return void
*/
public function testSetLoggersVerbose()
{
Log::drop('stdout');
Log::drop('stderr');
$this->io->setLoggers(ConsoleIo::VERBOSE);
$this->assertNotEmpty(Log::engine('stderr'));
$engine = Log::engine('stdout');
$this->assertEquals(['notice', 'info', 'debug'], $engine->config('levels'));
}
示例7: testLogFunction
/**
* Tests that the logged query object is passed to the built-in logger using
* the correct scope
*
* @return void
*/
public function testLogFunction()
{
$logger = new QueryLogger();
$query = new LoggedQuery();
$query->query = 'SELECT a FROM b where a = ? AND b = ? AND c = ?';
$query->params = ['string', '3', null];
$engine = $this->getMock('\\Cake\\Log\\Engine\\BaseLog', ['log'], ['scopes' => ['queriesLog']]);
Log::engine('queryLoggerTest', $engine);
$engine2 = $this->getMock('\\Cake\\Log\\Engine\\BaseLog', ['log'], ['scopes' => ['foo']]);
Log::engine('queryLoggerTest2', $engine2);
$engine2->expects($this->never())->method('log');
$logger->log($query);
}
示例8: testSetLoggers
/**
* Tests that setLoggers works properly
*
* @return void
*/
public function testSetLoggers()
{
Log::drop('stdout');
Log::drop('stderr');
$this->io->setLoggers(true);
$this->assertNotEmpty(Log::engine('stdout'));
$this->assertNotEmpty(Log::engine('stderr'));
$this->io->setLoggers(false);
$this->assertFalse(Log::engine('stdout'));
$this->assertFalse(Log::engine('stderr'));
}
示例9: _log
/**
* Log requests to Elastic Search.
*
* @param Request|array $context The context of the request made.
* @return void
*/
protected function _log($context)
{
if (!$this->logQueries) {
return;
}
if (!isset($this->_logger)) {
$this->_logger = Log::engine('elasticsearch') ?: new ElasticaLog();
}
if ($context instanceof Request) {
$data = $context->toArray();
} else {
$data = ['message' => $context];
}
$logData = ['method' => $data['method'], 'path' => $data['path'], 'data' => $data['data']];
$data = json_encode($logData, JSON_PRETTY_PRINT);
$loggedQuery = new LoggedQuery();
$loggedQuery->query = $data;
if ($this->_logger instanceof \Psr\Log\LoggerInterface) {
$this->_logger->log('debug', $loggedQuery);
} else {
$this->_logger->log($loggedQuery);
}
}
示例10: testPassingScopeToEngine
/**
* testPassingScopeToEngine method
*/
public function testPassingScopeToEngine()
{
Configure::write('App.namespace', 'TestApp');
Log::reset();
Log::config('scope_test', ['engine' => 'TestApp', 'types' => array('notice', 'info', 'debug'), 'scopes' => array('foo', 'bar')]);
$engine = Log::engine('scope_test');
$this->assertNull($engine->passedScope);
Log::write('debug', 'test message', 'foo');
$this->assertEquals(['scope' => ['foo']], $engine->passedScope);
Log::write('debug', 'test message', ['foo', 'bar']);
$this->assertEquals(['scope' => ['foo', 'bar']], $engine->passedScope);
$result = Log::write('debug', 'test message');
$this->assertFalse($result);
}