Apply any available decorators to the logger, if configured

@param LoggerInterface $logger
@param array $config

@return LoggerInterface
433704
private function applyDecorators(LoggerInterface $logger, array $config)
    {
        foreach ($this->decorators as $configKey => $decoratorClassName) {
            if (!isset($config[$configKey])) {
                continue;
            }
            if (!class_exists($decoratorClassName)) {
                throw new \RuntimeException('Decorator class not found: ' . $decoratorClassName);
            }
            if (!is_subclass_of($decoratorClassName, '\Phlib\Logger\Decorator\AbstractDecorator')) {
                throw new \RuntimeException('Decorator class invalid: ' . $decoratorClassName);
            }
            /** @var \Phlib\Logger\Decorator\AbstractDecorator $logger */
            $logger = new $decoratorClassName($logger, $config[$configKey]);
        }

        return $logger;
    }
1058235
public static function registerExceptionHandler(Logger $logger)
    {
        // Only register once per instance
        if (self::$registeredExceptionHandler) {
            return false;
        }

        if ($logger === null) {
            throw new \Zend\Log\Exception\InvalidArgumentException('Invalid Logger specified');
        }

        set_exception_handler(
                    /* var $exception Exception */
            function (\Exception $exception) use ($logger) {
                    $msg = '';
                    $prev = $exception->getPrevious();
                    while ($prev !== null) {
                        $msg .= PHP_EOL.'Previous: '.$prev->getMessage().
                                 ' in '.$prev->getFile().' in line '.
                                 $prev->getLine().'.';
                        $prev = $prev->getPrevious();
                    }
                    $logger->log(ErrorLogger::ERR,
                            'Exception: '.$exception->getMessage().' in '.
                                     $exception->getFile().' in line '.
                                     $exception->getLine().'.'.$msg.PHP_EOL.
                                     'Trace:'.PHP_EOL.
                                     $exception->getTraceAsString());
                });
        self::$registeredExceptionHandler = true;

        return false;
    }
866877
public function createProcessors(array $loggerConfig)
    {
        $processors = array();

        if (false === array_key_exists('processors', $loggerConfig)
            || false === is_array($loggerConfig['processors'])
        ) {
            return $processors;
        }

        foreach ($loggerConfig['processors'] as $processor) {
            if ('web' === $processor) {
                $webProcessor = new Monolog\Processor\WebProcessor();
                $webProcessor->addExtraField('user_agent', 'HTTP_USER_AGENT');
                $webProcessor->addExtraField('client_ip', 'HTTP_X_CLIENT_IP');

                $processors[] = $webProcessor;
            } elseif ('requestId' === $processor) {
                $processors[] = new Processor\RequestId();
            } else {
                throw new MonologCreator\Exception(
                    'processor type: ' . $processor . ' is not supported'
                );
            }
        }

        return $processors;
    }
379205
public function setLogger($logger)
    {
        $this->logger = $logger;
        $this->connection->getConfiguration()->setSQLLogger($this->logger);
        return $this;
    }
983210
public static function create($connectionConfigs, LoggerInterface $logger = null) {
        if (!is_null(self::$instance)) {
            throw new SqlException('ConnectionManager实例已创建，不能重复创建~');
        }

        self::$instance = new ConnectionManager($connectionConfigs, $logger);
        return self::$instance;
    }
1286724
public function setLogger($logger) {
		if(!in_array('Psr\Log\LoggerInterface', class_implements($logger, true))) {
			throw new \InvalidArgumentException('Logger object does not implement Psr\Log\LoggerInterface');
		}
		$this->logger = $logger;
	}
1205315
public function createHandlers(array $loggerConfig)
    {
        $handlers         = array();
        $formatterFactory = new MonologCreator\Factory\Formatter(
            $this->_config
        );
        $handlerFactory   = new MonologCreator\Factory\Handler(
            $this->_config,
            $this->_levels,
            $formatterFactory
        );

        foreach ($loggerConfig['handler'] as $handlerType) {
            $handlers[] = $handlerFactory->create(
                $handlerType,
                $loggerConfig['level']
            );
        }

        return $handlers;
    }
949869
public function setLogger(LoggerInterface $logger)
    {
        parent::setLogger($logger);
        foreach ($this->plugins as $plugin) {
            if (!($plugin instanceof LoggerAwareInterface)) {
                continue;
            }

            $plugin->setLogger($logger);
        }
    }
558733
protected function createLogDriver(array $config)
    {
        $logger = $this->app->make('Psr\Log\LoggerInterface');

        return new LogBroadcaster($this->app, $logger);
    }
164950
protected function tap($name, Logger $logger)
    {
        foreach ($this->configurationFor($name)['tap'] ?? [] as $tap) {
            [$class, $arguments] = $this->parseTap($tap);

            $this->app->make($class)->__invoke($logger, ...explode(',', $arguments));
        }

        return $logger;
    }
867157
public static function hasLogger($logger)
    {
        if ($logger instanceof Logger) {
            $index = array_search($logger, self::$loggers, true);

            return false !== $index;
        } else {
            return isset(self::$loggers[$logger]);
        }
    }
1357687
protected static function createLogFormatter(array $config) {
        if (isset($config['formatter'])) {
            switch ($config['formatter']) {
                case LogFormatter::class:
                    return new LogFormatter($config['format'], $config['date_format'], true);
                case LogstashFormatter::class:
                    return new LogstashFormatter($config['source_program'], $config['source_host'], 'extra_', 'ctx_', LogstashFormatter::V1);
            }
        }
        return new LogFormatter();
    }
860298
protected function buildHandlers(array $config):array
    {
        $handlers = [];
        foreach ($config as $handler) {
            $level = constant('\Mostofreddy\Loggy\Logger::'. strtoupper($handler['level']));
            $handlerObj = '\Mostofreddy\Loggy\Handler\\'.ucfirst($handler['handler']);
            $handlers[] = (new $handlerObj($level))->config($handler);
        }
        return $handlers;
    }
893405
public static function register(LoggerInterface $logger = null)
    {
        $handler = new static($logger);

        set_error_handler(array($handler, 'handleError'));
        register_shutdown_function(array($handler, 'handleFatalError'));

        set_exception_handler(array($handler, 'handleException'));
    }
1353319
public function addLogger($channel, LoggerInterface $logger)
    {
        $channel = strtolower($channel);

        $this->loggers[$channel] = $logger;

        return $this;
    }
539856
public function configure(Config $config)
    {
        $this->log_format    = $config->getString('log_format',self::DEFAULT_LOG_FORMAT);
        $this->log_encoding  = $config->getString('log_encoding','utf8');
        $this->log_levels    = $config->getList('log_levels',['T','D','I','W','E','F']);
    }
8489
public static function create($conf = array(), LoggerInterface $logger = null)
    {
        if (!$conf instanceof ConfigurationInterface) {
            $conf = new Configuration($conf);
        }

        $binaries = $conf->get('mp4box.binaries', array('MP4Box'));

        return static::load($binaries, $logger, $conf);
    }