本文整理汇总了PHP中Monolog\Logger::withName方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::withName方法的具体用法?PHP Logger::withName怎么用?PHP Logger::withName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::withName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* ShellMessagesHandler constructor.
* @param JupyterBroker $broker
* @param SocketWrapper $iopubSocket
* @param SocketWrapper $shellSocket
* @param Logger $logger
*/
public function __construct(JupyterBroker $broker, SocketWrapper $iopubSocket, SocketWrapper $shellSocket, Logger $logger)
{
$this->shellSoul = new Shell();
$this->executeAction = new ExecuteAction($broker, $iopubSocket, $shellSocket, $this->shellSoul);
$this->historyAction = new HistoryAction($broker, $shellSocket);
$this->kernelInfoAction = new KernelInfoAction($broker, $shellSocket, $iopubSocket);
$this->shutdownAction = new ShutdownAction($broker, $shellSocket);
$this->logger = $logger;
$broker->send($iopubSocket, 'status', ['execution_state' => 'starting'], []);
$this->shellSoul->setOutput(new KernelOutput($this->executeAction, $this->logger->withName('KernelOutput')));
}
示例2: registerHandlers
/**
*
*/
private function registerHandlers()
{
$this->hbSocket->on('error', new HbErrorHandler($this->logger->withName('HbErrorHandler')));
$this->hbSocket->on('messages', new HbMessagesHandler($this->logger->withName('HbMessagesHandler')));
$this->iopubSocket->on('messages', new IOPubMessagesHandler($this->logger->withName('IOPubMessagesHandler')));
$this->shellSocket->on('messages', new ShellMessagesHandler($this->broker, $this->iopubSocket, $this->shellSocket, $this->logger->withName('ShellMessagesHandler')));
}
示例3: testWithName
/**
* @covers Monolog\Logger::withName
*/
public function testWithName()
{
$first = new Logger('first', array($handler = new TestHandler()));
$second = $first->withName('second');
$this->assertSame('first', $first->getName());
$this->assertSame('second', $second->getName());
$this->assertSame($handler, $second->popHandler());
}
示例4: Logger
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
use Litipk\JupyterPHP\System\System;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\FingersCrossedHandler;
use Monolog\Handler\GroupHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogHandler;
use Monolog\Logger;
use Ramsey\Uuid\Uuid;
$system = System::getSystem();
$logger = new Logger('kernel');
$loggerActivationStrategy = new ErrorLevelActivationStrategy(LoggerSettings::getCrossFingersLevel());
if ('root' === $system->getCurrentUser()) {
if (System::OS_LINUX === $system->getOperativeSystem()) {
$logger->pushHandler(new FingersCrossedHandler(new GroupHandler([new SyslogHandler('jupyter-php'), new StreamHandler('php://stderr')]), $loggerActivationStrategy, 128));
}
} else {
$system->ensurePath($system->getAppDataDirectory() . '/logs');
$logger->pushHandler(new FingersCrossedHandler(new GroupHandler([new RotatingFileHandler($system->getAppDataDirectory() . '/logs/error.log', 7), new StreamHandler('php://stderr')]), $loggerActivationStrategy, 128));
}
try {
// Obtain settings
$connectionSettings = ConnectionSettings::get();
$connUris = ConnectionSettings::getConnectionUris($connectionSettings);
$kernelCore = new KernelCore(new JupyterBroker($connectionSettings['key'], $connectionSettings['signature_scheme'], Uuid::uuid4(), $logger->withName('JupyterBroker')), $connUris, $logger->withName('KernelCore'));
$kernelCore->run();
} catch (\Exception $e) {
$logger->error('Unexpected error', ['exception' => $e]);
}