Browscap\Helper\LoggerHelper::create PHP Method

create() public method

creates a \Monolo\Logger instance
public create ( boolean $debug = false ) : Logger
$debug boolean If true the debug logging mode will be enabled
return Monolog\Logger
    public function create($debug = false)
    {
        $logger = new Logger('browscap');
        if ($debug) {
            $stream = new StreamHandler('php://output', Logger::DEBUG);
            $stream->setFormatter(new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %extra%' . "\n"));
            /** @var callable $memoryProcessor */
            $memoryProcessor = new MemoryUsageProcessor(true);
            $logger->pushProcessor($memoryProcessor);
            /** @var callable $peakMemoryProcessor */
            $peakMemoryProcessor = new MemoryPeakUsageProcessor(true);
            $logger->pushProcessor($peakMemoryProcessor);
        } else {
            $stream = new StreamHandler('php://output', Logger::INFO);
            $stream->setFormatter(new LineFormatter('[%datetime%] %message% %extra%' . "\n"));
            /** @var callable $peakMemoryProcessor */
            $peakMemoryProcessor = new MemoryPeakUsageProcessor(true);
            $logger->pushProcessor($peakMemoryProcessor);
        }
        $logger->pushHandler($stream);
        $logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, Logger::NOTICE));
        ErrorHandler::register($logger);
        return $logger;
    }

Usage Example

Beispiel #1
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|integer null or 0 if everything went fine, or an error code
  *
  * @throws \LogicException When this abstract method is not implemented
  * @see    setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $loggerHelper = new LoggerHelper();
     $logger = $loggerHelper->create($input->getOption('debug'));
     $logger->info('Build started.');
     $buildFolder = $input->getOption('output');
     $buildGenerator = new BuildGenerator($input->getOption('resources'), $buildFolder);
     $writerCollectionFactory = new FullCollectionFactory();
     $writerCollection = $writerCollectionFactory->createCollection($logger, $buildFolder);
     $buildGenerator->setLogger($logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection);
     $buildGenerator->run($input->getArgument('version'));
     $logger->info('Build done.');
 }
All Usage Examples Of Browscap\Helper\LoggerHelper::create
LoggerHelper