You are here

class Logger in Zircon Profile 8

Same name in this branch
  1. 8 vendor/wikimedia/composer-merge-plugin/src/Logger.php \Wikimedia\Composer\Logger
  2. 8 vendor/symfony/http-kernel/Tests/Logger.php \Symfony\Component\HttpKernel\Tests\Logger
Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/Logger.php \Wikimedia\Composer\Logger

Simple logging wrapper for Composer\IO\IOInterface

@author Bryan Davis <bd808@bd808.com>

Hierarchy

  • class \Wikimedia\Composer\Logger

Expanded class hierarchy of Logger

1 file declares its use of Logger
ExtraPackage.php in vendor/wikimedia/composer-merge-plugin/src/Merge/ExtraPackage.php

File

vendor/wikimedia/composer-merge-plugin/src/Logger.php, line 20

Namespace

Wikimedia\Composer
View source
class Logger {

  /**
   * @var string $name
   */
  protected $name;

  /**
   * @var IOInterface $inputOutput
   */
  protected $inputOutput;

  /**
   * @param string $name
   * @param IOInterface $io
   */
  public function __construct($name, IOInterface $io) {
    $this->name = $name;
    $this->inputOutput = $io;
  }

  /**
   * Log a debug message
   *
   * Messages will be output at the "very verbose" logging level (eg `-vv`
   * needed on the Composer command).
   *
   * @param string $message
   */
  public function debug($message) {
    if ($this->inputOutput
      ->isVeryVerbose()) {
      $message = "  <info>[{$this->name}]</info> {$message}";
      $this
        ->log($message);
    }
  }

  /**
   * Log an informative message
   *
   * Messages will be output at the "verbose" logging level (eg `-v` needed
   * on the Composer command).
   *
   * @param string $message
   */
  public function info($message) {
    if ($this->inputOutput
      ->isVerbose()) {
      $message = "  <info>[{$this->name}]</info> {$message}";
      $this
        ->log($message);
    }
  }

  /**
   * Log a warning message
   *
   * @param string $message
   */
  public function warning($message) {
    $message = "  <error>[{$this->name}]</error> {$message}";
    $this
      ->log($message);
  }

  /**
   * Write a message
   *
   * @param string $message
   */
  protected function log($message) {
    if (method_exists($this->inputOutput, 'writeError')) {
      $this->inputOutput
        ->writeError($message);
    }
    else {

      // @codeCoverageIgnoreStart
      // Backwards compatiblity for Composer before cb336a5
      $this->inputOutput
        ->write($message);

      // @codeCoverageIgnoreEnd
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Logger::$inputOutput protected property
Logger::$name protected property
Logger::debug public function Log a debug message
Logger::info public function Log an informative message
Logger::log protected function Write a message
Logger::warning public function Log a warning message
Logger::__construct public function