public function __construct($callableString) { if (!is_callable($callableString)) { LoggerPolicy::processConfigurationError("'{$callableString}' is not callable"); return; } $this->callable = $callableString; }
public function getLayout($name) { if (!isset($this->layoutMap[$name])) { LoggerPolicy::processConfigurationError("Layout {$name} not found"); return new LayoutSimple(); } return $this->layoutMap[$name]; }
public function __construct($path) { if ($path) { $this->path = preg_split('/\\./', $path, -1, PREG_SPLIT_NO_EMPTY); } if (!$this->path) { LoggerPolicy::processConfigurationError('path is required'); $this->path = []; } }
/** * @param string $streamName * * @throws LoggerConfigurationException */ public function setStream($streamName) { switch ($streamName) { case 'STDOUT': $this->stream = self::STDOUT; return; case 'STDERR': $this->stream = self::STDERR; return; default: LoggerPolicy::processConfigurationError("Stream must be STDOUT or STDERR, got '{$streamName}'"); return; } }
/** * @param LoggerHierarchy $hierarchy * @param $config * * @return AppenderAbstract * * @throws LoggerException */ private function createAppender(LoggerHierarchy $hierarchy, $config) { if (isset($config['layout'])) { if (is_string($config['layout'])) { $config['layout'] = $hierarchy->getLayout($config['layout']); } elseif (is_array($config['layout'])) { $config['layout'] = $this->createLayout($config['layout']); } else { LoggerPolicy::processConfigurationError('Invalid logger layout description'); unset($config['layout']); } } /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->createObject($config); }