本文整理汇总了PHP中Monolog\Logger::getHandlers方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::getHandlers方法的具体用法?PHP Logger::getHandlers怎么用?PHP Logger::getHandlers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::getHandlers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
public function process(AMQPMessage $message)
{
$handlers = $this->logger->getHandlers();
if (empty($handlers)) {
throw new \Exception('No handlers registered');
}
$this->logger->critical($message->body);
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
}
示例2: testErrorLogHandlerAssertions
public function testErrorLogHandlerAssertions()
{
$handlers = $this->log->getHandlers();
$hasErrorHandler = false;
foreach ($handlers as $handler) {
if (!$handler instanceof ErrorLogHandler) {
continue;
}
$hasErrorHandler = true;
$this->assertEquals(Logger::ERROR, $handler->getLevel());
}
$this->assertTrue($hasErrorHandler);
}
示例3: testRollbackLogsProfileData
public function testRollbackLogsProfileData()
{
$this->pdo->beginTransaction();
$this->pdo->rollBack();
/** @var TestHandler $handler */
$handlers = $this->logger->getHandlers();
$handler = $handlers[0];
$this->assertTrue($handler->hasDebugThatContains('rollBack'));
}
示例4: initialize
/**
* Initialize
*
* Initilize monolog instance. Singleton
* Is possbile provide an external monolog instance
*
* @param \Monolog\Logger
*
* @return \Monolog\Logger
*/
public static function initialize(Logger $external_monolog = null)
{
if (self::$monolog === null) {
if ($external_monolog !== null) {
self::$monolog = $external_monolog;
foreach (self::$monolog->getHandlers() as $handler) {
if ($handler->getLevel() == 400) {
self::$error_log_path = true;
}
if ($handler->getLevel() == 100) {
self::$debug_log_path = true;
}
}
} else {
self::$monolog = new Logger('bot_log');
}
}
return self::$monolog;
}
示例5: testRecordStructureForException
public function testRecordStructureForException()
{
$pushbullet = Mockery::mock('pushbullet');
$pushbullet->shouldReceive('user->note')->once();
$logger = new Logger('MonobulletTest');
$logger->pushHandler(new Handler($pushbullet, null));
$logger->info('exception \'ErrorException\' with message \'Undefined property: stdClass::$dummy\' in /tmp/non-existant.php:27' . PHP_EOL . 'Stack trace:' . PHP_EOL . '#0 /tmp/04227d.php(27): HandleExceptions->handleError(8, \'Undefined prope...\', \'/tmp/non-exi...\', 27, Array)' . PHP_EOL . '#1 /tmp/AnotherDummy.php(42): include(\'/tmp/non-exis...\')' . PHP_EOL . '#2 /tmp/WowStillDummy.php(59): Method->DumDum(\'/tmp/che...\', Array)');
$record = $logger->getHandlers()[0]->getLastRecord();
$this->assertArrayHasKey('formatted', $record);
$this->assertArrayHasKey('title', $record['formatted']);
$this->assertArrayHasKey('stack', $record['formatted']['extra']);
}
示例6: getLogger
/**
* Get logger.
*
* @return null|LoggerInterface
*/
public function getLogger()
{
if (null === $this->logger) {
$logger = new Logger(Commander::LOGGER_NAME);
foreach ($this->getHandlers() as $handler) {
$logger->pushHandler($handler);
}
if (0 === count($logger->getHandlers())) {
return null;
}
$this->logger = $logger;
}
return $this->logger;
}
示例7: testSetHandlers
/**
* @covers Monolog\Logger::setHandlers
*/
public function testSetHandlers()
{
$logger = new Logger(__METHOD__);
$handler1 = new TestHandler();
$handler2 = new TestHandler();
$logger->pushHandler($handler1);
$logger->setHandlers(array($handler2));
// handler1 has been removed
$this->assertEquals(array($handler2), $logger->getHandlers());
$logger->setHandlers(array("AMapKey" => $handler1, "Woop" => $handler2));
// Keys have been scrubbed
$this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
}
示例8: getHandlers
/**
*
*
* @return \Monolog\HandlerInterface[]
* @static
*/
public static function getHandlers()
{
return \Monolog\Logger::getHandlers();
}
示例9: __construct
/**
* DynamicLogger constructor.
*/
public function __construct()
{
$this->logger = Log::getMonolog();
$this->handlers = $this->logger->getHandlers();
}
示例10: getLogger
/**
* Initialize logging.
*/
protected function getLogger()
{
$logger = new Logger('currycms');
foreach ($this['log'] as $log) {
if (isset($log['enabled']) && !$log['enabled']) {
continue;
}
$clazz = new \ReflectionClass($log['type']);
$arguments = isset($log['arguments']) ? $log['arguments'] : array();
$handler = $clazz->newInstanceArgs($arguments);
if (isset($log['buffer']) && $log['buffer']) {
$handler = new BufferHandler($handler);
}
if (isset($log['fingersCrossed']) && $log['fingersCrossed']) {
$handler = new FingersCrossedHandler($handler);
}
$logger->pushHandler($handler);
}
if (!count($logger->getHandlers())) {
$logger->pushHandler(new NullHandler());
}
if ($this['developmentMode']) {
$logger->pushProcessor(new IntrospectionProcessor(Logger::WARNING));
}
return $logger;
}
示例11: getHandlers
/**
* @return \Monolog\Handler\HandlerInterface[]
*/
public function getHandlers()
{
return parent::getHandlers();
}