Esempio n. 1
0
 /**
  * @param resource $stream
  * @param integer  $level  The minimum logging level at which this handler will be triggered
  * @param Boolean  $bubble Whether the messages that are handled can bubble up the stack or not
  */
 public function addDBHandler($stream = null, $level = \Monolog\Logger::DEBUG, $bubble = true)
 {
     if (empty($stream)) {
         $stream = new DBHandler($this->logger->getName() . '_log', $level, $bubble);
     }
     $this->logger->pushHandler($stream);
 }
 /**
  * Adds new logging channel to the registry
  *
  * @param  Logger      $logger    Instance of the logging channel
  * @param  string|null $name      Name of the logging channel ($logger->getName() by default)
  * @param  boolean     $overwrite Overwrite instance in the registry if the given name already exists?
  * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists
  */
 public static function addLogger(Logger $logger, $name = null, $overwrite = false)
 {
     $name = $name ?: $logger->getName();
     if (isset(self::$loggers[$name]) && !$overwrite) {
         throw new InvalidArgumentException('Logger with the given name already exists');
     }
     self::$loggers[$name] = $logger;
 }
Esempio n. 3
0
 /**
  * @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());
 }
Esempio n. 4
0
 /**
  * @param Logger $Logger Logger to configure
  * @param array $config handlers configuration
  *
  * @throws HandlerClassMissingException
  * @throws SectionArgsMissingException
  */
 protected function configureHandlers(Logger $Logger, array $config)
 {
     foreach ($config as $handlerConfig) {
         if (!isset($handlerConfig[Config::HANDLER_CLASS])) {
             throw new HandlerClassMissingException('Handler class is missing for [' . $Logger->getName() . '] log');
         }
         if (!isset($handlerConfig[Config::HANDLER_ARGS])) {
             throw new SectionArgsMissingException('Section args is missing for [' . $Logger->getName() . '] log');
         }
         $Reflector = new ReflectionClass($handlerConfig[Config::HANDLER_CLASS]);
         /** @var HandlerInterface $AbstractHandler */
         $AbstractHandler = $Reflector->newInstanceArgs($handlerConfig[Config::HANDLER_ARGS]);
         if (isset($handlerConfig[Config::HANDLER_FORMATTER])) {
             $this->configureFormatter($Logger, $AbstractHandler, $handlerConfig[Config::HANDLER_FORMATTER]);
         }
         $Logger->pushHandler($AbstractHandler);
     }
 }
Esempio n. 5
0
 /**
  * @covers Monolog\Logger::getName
  */
 public function testGetName()
 {
     $logger = new Logger('foo');
     $this->assertEquals('foo', $logger->getName());
 }
 /**
  * 
  *
  * @return string 
  * @static 
  */
 public static function getName()
 {
     return \Monolog\Logger::getName();
 }
#!/usr/bin/env php
<?php 
// Bring in the dependencies
require_once __DIR__ . "/vendor/autoload.php";
use Monolog\Logger;
use LeeSherwood\Ejabberd\AuthenticationService;
use LeeSherwood\Ejabberd\CommandExecutors\DummyCommandExecutor;
// Setup Logger
$logger = new Logger('ejabberdAuth');
// Create the log handler(s) (lower the logging level for more verbosity)
$syslogHandler = new Monolog\Handler\SyslogHandler($logger->getName(), LOG_SYSLOG, Logger::DEBUG);
// Attach the handler
$logger->pushHandler($syslogHandler);
// Setup command executor
$executor = new DummyCommandExecutor();
// Boot the service
$application = new AuthenticationService($logger, $executor);
// Execute the run loop
$application->run();
Esempio n. 8
0
 /**
  * @return string
  */
 public function getName()
 {
     return parent::getName();
 }
Esempio n. 9
0
 /**
  * @param Logger $logger
  */
 public function clear(Logger $logger)
 {
     $this->db->exec(sprintf('DELETE FROM `%s` WHERE `channel` = ?', $this->table), [$logger->getName()]);
 }
 /**
  * Get the current channel name
  *
  * @return string
  */
 public function getChannelName()
 {
     return $this->channel->getName();
 }