コード例 #1
0
 public function __construct($callableString)
 {
     if (!is_callable($callableString)) {
         LoggerPolicy::processConfigurationError("'{$callableString}' is not callable");
         return;
     }
     $this->callable = $callableString;
 }
コード例 #2
0
 public function getLayout($name)
 {
     if (!isset($this->layoutMap[$name])) {
         LoggerPolicy::processConfigurationError("Layout {$name} not found");
         return new LayoutSimple();
     }
     return $this->layoutMap[$name];
 }
コード例 #3
0
 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 = [];
     }
 }
コード例 #4
0
ファイル: AppenderStd.php プロジェクト: mitallast/php-logger
 /**
  * @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;
     }
 }
コード例 #5
0
 /**
  * @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);
 }