Beispiel #1
0
 /**
  * Adds new logging channel to the registry
  *
  * @param Monolog_Logger $logger    Instance of the logging channel
  * @param string|null    $name      Name of the logging channel ($logger->getName() by default)
  * @param boolean        $overwrite Overwrite instance in the registry if the given name already exists?
  *
  * @throws InvalidArgumentException If $overwrite set to false and named Logger instance already exists
  */
 public static function addLogger(Monolog_Logger $logger, $name = null, $overwrite = false)
 {
     $name = $name ? $name : $logger->getName();
     if (isset(self::$loggers[$name]) && !$overwrite) {
         throw new InvalidArgumentException('Logger with the given name already exists');
     }
     self::$loggers[$name] = $logger;
 }
Beispiel #2
0
 private function getCurrentTimestamp()
 {
     if (!self::$timezone) {
         self::$timezone = new DateTimeZone(date_default_timezone_get() ? date_default_timezone_get() : 'UTC');
     }
     if (is_callable(array('DateTime', 'createFromFormat'))) {
         /** @handled static */
         return DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), self::$timezone)->setTimezone(self::$timezone);
     }
     return new DateTime('now', self::$timezone);
 }