setLogger() public method

Set repository logger.
public setLogger ( Psr\Log\LoggerInterface $logger ) : Repository
$logger Psr\Log\LoggerInterface A logger
return Repository The current repository
 /**
  * Injects Logger inside the repository.
  */
 public function addRepository(Repository $repository)
 {
     if (null !== $repository->getLogger()) {
         throw new \RuntimeException('A logger is already injected in repository.');
     }
     $name = $repository->getGitDir();
     $logger = new Logger($name);
     $handler = new TestHandler();
     $logger->pushHandler($handler);
     $this->handlers[$name] = $handler;
     $repository->setLogger($logger);
 }
Beispiel #2
0
 /**
  * Get git repo for this module
  *
  * @param OutputInterface $output Optional output to log to
  * @return Repository
  */
 public function getRepository(OutputInterface $output = null)
 {
     $repo = new Repository($this->directory, array('environment_variables' => array('HOME' => getenv('HOME'), 'SSH_AUTH_SOCK' => getenv('SSH_AUTH_SOCK'))));
     // Include logger if requested
     if ($output) {
         $logger = new ConsoleLogger($output);
         $repo->setLogger($logger);
     }
     return $repo;
 }