Exemple #1
0
 /**
  * Returns a Logger by name. If it does not exist, it will be created.
  *
  * @param string $name The logger name
  *
  * @return Logger
  */
 public static function getLogger($name)
 {
     if (!self::$isConfigured) {
         static::configure();
     }
     return self::$hierarchy->getLogger($name);
 }
 public function testGetLoggerCreate()
 {
     $rootLogger = new Logger('root');
     $hierarchy = new LoggerHierarchy();
     $hierarchy->setRootLogger($rootLogger);
     $logger = $hierarchy->getLogger('newLogger');
     $this->assertSame('newLogger', $logger->getName());
     $this->assertSame($rootLogger, $logger->getParent());
     $this->assertSame(['newLogger' => $logger], $hierarchy->getLoggerMap());
 }