当前位置: 首页>>代码示例>>PHP>>正文


PHP ErrorHandler::setLogger方法代码示例

本文整理汇总了PHP中Symfony\Component\Debug\ErrorHandler::setLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP ErrorHandler::setLogger方法的具体用法?PHP ErrorHandler::setLogger怎么用?PHP ErrorHandler::setLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Debug\ErrorHandler的用法示例。


在下文中一共展示了ErrorHandler::setLogger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: injectLogger

 public function injectLogger()
 {
     if (null !== $this->logger) {
         ErrorHandler::setLogger($this->logger, $this->channel);
         $this->logger = null;
     }
 }
开发者ID:GeorgeBroadley,项目名称:caffeine-vendor,代码行数:7,代码来源:ErrorsLoggerListener.php

示例2: register

 public function register(\Pimple\Container $pimple)
 {
     $pimple['debugbar.http_driver.drupal'] = function (\Pimple\Container $c) {
         return new DrupalHttpDriver();
     };
     $pimple['debugbar.collector.drupal_database'] = function ($c) {
         return new DrupalDbTngCollector();
     };
     $pimple['debugbar.collector.time_data'] = function ($c) {
         return new DrupalTimeDataCollector();
     };
     $pimple['debugbar.collector.menu_item'] = function ($c) {
         $item = menu_get_item();
         if (!$item) {
             $item = array();
         }
         return new \DebugBar\DataCollector\ConfigCollector($item, 'Menu');
     };
     $pimple['debugbar.collector.globals'] = function ($c) {
         return new GlobalsConfigCollector();
     };
     $pimple['debugbar.storage.drupal'] = function ($c) {
         /** @var \PDO $pdo */
         $pdo = $c['db']->getWrappedConnection();
         return new \DebugBar\Storage\PdoStorage($pdo);
     };
     $pimple['debugbar.storage.file'] = function ($c) {
         return new \DebugBar\Storage\FileStorage('var://debugbar');
     };
     $pimple->extend('debugbar', function (\DebugBar\DebugBar $debugbar, \Pimple\Container $c) {
         $debugbar->setStorage($c['debugbar.storage.drupal']);
         $debugbar->setHttpDriver($c['debugbar.http_driver.drupal']);
         \Symfony\Component\Debug\ErrorHandler::setLogger($c['debugbar.collector.messages'], 'scream');
         set_exception_handler(array($c['debugbar.collector.exceptions'], 'addException'));
         return $debugbar;
     });
     $pimple->extend('debugbar.renderer', function (\DebugBar\JavascriptRenderer $renderer, \Pimple\Container $c) {
         $renderer->setOpenHandlerUrl('/debugbar/open');
         return $renderer;
     });
 }
开发者ID:drufony,项目名称:debugbar-module,代码行数:41,代码来源:DrupalDebugbarServiceProvider.php

示例3: __construct

 /**
  * Called directly from index.php
  * Starts up the Symfony components and the FoolFrame components
  */
 public function __construct()
 {
     $this->container = new ContainerBuilder();
     $this->container->register('profiler', 'Foolz\\Profiler\\Profiler')->addMethodCall('enable', []);
     $this->profiler = $this->container->get('profiler');
     class_alias('Foolz\\FoolFrame\\Model\\Plugins', 'Plugins');
     class_alias('Foolz\\FoolFrame\\Model\\SchemaManager', 'SchemaManager');
     class_alias('Foolz\\FoolFrame\\Model\\System', 'System');
     class_alias('Foolz\\FoolFrame\\Model\\User', 'User');
     class_alias('Foolz\\FoolFrame\\Model\\Users', 'Users');
     $this->route_collection = new RouteCollection();
     $this->logger = new MonoLogger('foolframe');
     $this->logger->pushHandler(new RotatingFileHandler(VAPPPATH . 'foolz/foolframe/logs/foolframe.log', 7, MonoLogger::WARNING));
     $this->logger->pushProcessor(new IntrospectionProcessor());
     $this->logger->pushProcessor(new WebProcessor());
     // special logger that saves stack traces from the exception handler
     $this->logger_trace = new MonoLogger('foolframe_trace');
     $this->logger_trace->pushHandler(new RotatingFileHandler(VAPPPATH . 'foolz/foolframe/logs/foolframe_trace.log', 7, MonoLogger::WARNING));
     $this->logger_trace->pushProcessor(new IntrospectionProcessor());
     $this->logger_trace->pushProcessor(new WebProcessor());
     if ('cli' !== php_sapi_name()) {
         error_reporting(-1);
         $this->error_handler = ErrorHandler::register();
         $this->error_handler->setLogger($this->logger_trace);
         $this->exception_handler = ExceptionHandler::register(false);
         $this->exception_handler->setLogger($this->logger);
         $this->exception_handler->setLoggerTrace($this->logger_trace);
     } elseif (!ini_get('log_errors') || ini_get('error_log')) {
         ini_set('display_errors', 1);
     }
     $this->container->register('autoloader', 'Foolz\\FoolFrame\\Model\\Autoloader')->addArgument($this)->addMethodCall('register');
     $this->container->register('logger', 'Foolz\\FoolFrame\\Model\\Logger')->addArgument($this)->addMethodCall('addLogger', [$this->logger])->addMethodCall('addLogger', [$this->logger_trace]);
     $this->container->register('config', 'Foolz\\FoolFrame\\Model\\Config')->addArgument($this);
     $this->container->register('doctrine', 'Foolz\\FoolFrame\\Model\\DoctrineConnection')->addArgument($this)->addArgument(new Reference('config'));
     $this->container->register('mailer', 'Foolz\\FoolFrame\\Model\\Mailer')->addArgument($this);
     $this->container->register('preferences', 'Foolz\\FoolFrame\\Model\\Preferences')->addArgument($this);
     $this->container->register('plugins', 'Foolz\\FoolFrame\\Model\\Plugins')->addArgument($this);
     $this->container->register('users', 'Foolz\\FoolFrame\\Model\\Users')->addArgument($this);
     $this->container->register('auth', 'Foolz\\FoolFrame\\Model\\Auth')->addArgument($this);
     $this->container->register('security', 'Foolz\\FoolFrame\\Model\\Security')->addArgument($this);
     $this->config = $this->getService('config');
     $this->preferences = $this->getService('preferences');
     // start up the caching system
     $caching_config = $this->config->get('foolz/foolframe', 'cache', '');
     switch ($caching_config['type']) {
         case 'redis':
             $mem_config = \Foolz\Cache\Config::forgeRedis();
             $mem_config->setFormat($caching_config['format']);
             $mem_config->setPrefix($caching_config['prefix']);
             $mem_config->setServers($caching_config['servers']);
             $mem_config->setThrow(true);
             Cache::instantiate($mem_config);
             break;
         case 'memcached':
             $mem_config = \Foolz\Cache\Config::forgeMemcached();
             $mem_config->setFormat($caching_config['format']);
             $mem_config->setPrefix($caching_config['prefix']);
             $mem_config->setServers($caching_config['servers']);
             $mem_config->setThrow(true);
             Cache::instantiate($mem_config);
             break;
         case 'apc':
             $apc_config = \Foolz\Cache\Config::forgeApc();
             $apc_config->setFormat($caching_config['format']);
             $apc_config->setPrefix($caching_config['prefix']);
             $apc_config->setThrow(true);
             Cache::instantiate($apc_config);
             break;
         case 'dummy':
             $dummy_config = \Foolz\Cache\Config::forgeDummy();
             $dummy_config->setFormat($caching_config['format']);
             $dummy_config->setPrefix($caching_config['prefix']);
             $dummy_config->setThrow(true);
             Cache::instantiate($dummy_config);
             break;
     }
     // run the Framework class for each module
     foreach ($this->config->get('foolz/foolframe', 'config', 'modules.installed') as $module) {
         if ($module['namespace'] !== 'foolz/foolframe') {
             $context = $module['context'];
             $this->child_contextes[$module['namespace']] = new $context($this);
         }
     }
     $this->profiler->log('Start Plugin instantiation');
     if (count($this->child_contextes)) {
         $this->getService('plugins')->instantiate();
     }
     $this->profiler->log('Stop Plugin instantiation');
 }
开发者ID:KasaiDot,项目名称:FoolFrame,代码行数:93,代码来源:Context.php

示例4: use

<?php

use Silex\Application;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use Symfony\Component\Debug\ErrorHandler;
// Handler de Errors
$app->before(function (SymfonyRequest $request) use($app) {
    if ($app['debug'] !== true) {
        ErrorHandler::setLogger($app['monolog'], 'emergency');
        ErrorHandler::register();
    }
}, Application::EARLY_EVENT);
// Route de Error
$app->error(function (\Exception $exception, $code) use($app) {
    switch ($code) {
        case 404:
            // Pagina não encontrada
            $view = 'errors/404.html';
            break;
        case 403:
            // Sem Permissão
            $view = 'errors/403.html';
            break;
        default:
            $view = 'errors/error.html';
            break;
    }
    return $app['twig']->render($view, compact('exception', 'code'));
});
开发者ID:naturalweb,项目名称:nwsilex-skeleton,代码行数:29,代码来源:errors.php


注:本文中的Symfony\Component\Debug\ErrorHandler::setLogger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。