diff options
| author | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-05-11 14:59:59 +0200 |
|---|---|---|
| committer | Stefan Suhren <suhren.stefan@fh-swf.de> | 2015-05-11 14:59:59 +0200 |
| commit | fa3a4e440f6daf241772331eaac322f3e0447750 (patch) | |
| tree | ee47dce337a8eecb67da391d6b91768d09d22e6e /vendor/symfony/console/Symfony/Component/Console/Logger | |
| parent | 1bb6c3bc23d08851f6af786f516b3cbc73a6f391 (diff) | |
| download | Catalog-fa3a4e440f6daf241772331eaac322f3e0447750.tar.gz Catalog-fa3a4e440f6daf241772331eaac322f3e0447750.zip | |
Let composer manage the vendor and lock files
Diffstat (limited to 'vendor/symfony/console/Symfony/Component/Console/Logger')
| -rw-r--r-- | vendor/symfony/console/Symfony/Component/Console/Logger/ConsoleLogger.php | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/vendor/symfony/console/Symfony/Component/Console/Logger/ConsoleLogger.php b/vendor/symfony/console/Symfony/Component/Console/Logger/ConsoleLogger.php deleted file mode 100644 index cf5d49c..0000000 --- a/vendor/symfony/console/Symfony/Component/Console/Logger/ConsoleLogger.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Logger; - -use Psr\Log\AbstractLogger; -use Psr\Log\InvalidArgumentException; -use Psr\Log\LogLevel; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\ConsoleOutputInterface; - -/** - * PSR-3 compliant console logger - * - * @author Kévin Dunglas <dunglas@gmail.com> - * @link http://www.php-fig.org/psr/psr-3/ - */ -class ConsoleLogger extends AbstractLogger -{ - const INFO = 'info'; - const ERROR = 'error'; - - /** - * @var OutputInterface - */ - private $output; - /** - * @var array - */ - private $verbosityLevelMap = array( - LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL, - LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL, - LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL, - LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL, - LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL, - LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE, - LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE, - LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG, - ); - /** - * @var array - */ - private $formatLevelMap = array( - LogLevel::EMERGENCY => self::ERROR, - LogLevel::ALERT => self::ERROR, - LogLevel::CRITICAL => self::ERROR, - LogLevel::ERROR => self::ERROR, - LogLevel::WARNING => self::INFO, - LogLevel::NOTICE => self::INFO, - LogLevel::INFO => self::INFO, - LogLevel::DEBUG => self::INFO, - ); - - /** - * @param OutputInterface $output - * @param array $verbosityLevelMap - * @param array $formatLevelMap - */ - public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array()) - { - $this->output = $output; - $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap; - $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap; - } - - /** - * {@inheritdoc} - */ - public function log($level, $message, array $context = array()) - { - if (!isset($this->verbosityLevelMap[$level])) { - throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); - } - - // Write to the error output if necessary and available - if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) { - $output = $this->output->getErrorOutput(); - } else { - $output = $this->output; - } - - if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) { - $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context))); - } - } - - /** - * Interpolates context values into the message placeholders - * - * @author PHP Framework Interoperability Group - * - * @param string $message - * @param array $context - * - * @return string - */ - private function interpolate($message, array $context) - { - // build a replacement array with braces around the context keys - $replace = array(); - foreach ($context as $key => $val) { - if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { - $replace[sprintf('{%s}', $key)] = $val; - } - } - - // interpolate replacement values into the message and return - return strtr($message, $replace); - } -} |
