Page MenuHomePhabricator

Swap all our process logging to Civi::log('wmf') from watchdog()
Open, Needs TriagePublic

Description

We have some process control inconsistencies at the moment :-( and it's logging it all at the end

Note the monolog extension is what is outputting the Civi::log('wmf')

Relevant code

/**
  * Add FirePhp Logger.
  *
  * See https://firephp.org/
  *
  * @param string $channel
  * @param \Monolog\Logger $logger
  * @param string $minimumLevel
  * @param bool $isFinal
  *
  * @noinspection PhpUnusedParameterInspection
  */
 protected function addStdOutLogger(string $channel, Logger $logger, string $minimumLevel, bool $isFinal): void {
   if (PHP_SAPI === 'cli') {
     global $argv;
     // The wordpress handler has this rather nice idea of respecting command
     // line efforts to increase or decrease logging levels.
     $modifiers = [
       // Drush parameters https://groups.drupal.org/drush/commands
       '-v' =>  'notice',
       '--verbose' => 'notice',
       '--debug' => 'debug',
       '-d' => 'debug',
       '-q' => 'error',
       '--quiet' => 'error',
       // https://symfony.com/doc/current/logging/monolog_console.html
       '-vv' => 'info',
       '-vvv' => 'debug',
     ];
     foreach ($argv as $argument) {
       if (isset($modifiers[$argument])) {
         $minimumLevel = $modifiers[$argument];
       }
     }
     $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%", NULL, TRUE, TRUE);
     $handler = new StreamHandler('php://stdout', $minimumLevel, !$isFinal);
     $handler->setFormatter($formatter);
     $logger->pushHandler($handler);
   }
 }