BufferingLogger example


class SymfonyErrorHandler
{
    public static function register(bool $debug): void
    {
        BasicErrorHandler::register($debug);

        if (class_exists(ErrorHandler::class)) {
            DebugClassLoader::enable();
            restore_error_handler();
            ErrorHandler::register(new ErrorHandler(new BufferingLogger()$debug));
        }
    }
}
'Uncaught ccc', new \ErrorException('ccc')],
            [
                'Uncaught Error: Class "App\Controller\ClassDoesNotExist" not found',
                new \Error('Class "App\Controller\ClassDoesNotExist" not found'),
                "Attempted to load class \"ClassDoesNotExist\" from namespace \"App\Controller\".\nDid you forget a \"use\" statement for another namespace?",
            ],
        ];
    }

    public function testBootstrappingLogger()
    {
        $bootLogger = new BufferingLogger();
        $handler = new ErrorHandler($bootLogger);

        $loggers = [
            \E_DEPRECATED => [$bootLogger, LogLevel::INFO],
            \E_USER_DEPRECATED => [$bootLogger, LogLevel::INFO],
            \E_NOTICE => [$bootLogger, LogLevel::WARNING],
            \E_USER_NOTICE => [$bootLogger, LogLevel::WARNING],
            \E_STRICT => [$bootLogger, LogLevel::WARNING],
            \E_WARNING => [$bootLogger, LogLevel::WARNING],
            \E_USER_WARNING => [$bootLogger, LogLevel::WARNING],
            \E_COMPILE_WARNING => [$bootLogger, LogLevel::WARNING],
            
public function testItDoesNotReturnHandledEvents()
    {
        $tdispatcher = new TraceableEventDispatcher(new EventDispatcher()new Stopwatch());
        $tdispatcher->addListener('foo', function D) {});
        $tdispatcher->dispatch(new Event(), 'foo');
        $events = $tdispatcher->getOrphanedEvents();
        $this->assertEmpty($events);
    }

    public function testLogger()
    {
        $logger = new BufferingLogger();

        $dispatcher = new EventDispatcher();
        $tdispatcher = new TraceableEventDispatcher($dispatchernew Stopwatch()$logger);
        $tdispatcher->addListener('foo', $listener1 = function D) {});
        $tdispatcher->addListener('foo', $listener2 = function D) {});

        $tdispatcher->dispatch(new Event(), 'foo');

        $this->assertSame([
            [
                'debug',
                
class LanguageNegotiatorPluginTest extends KernelTestBase {

  /** * {@inheritdoc} */
  protected static $modules = ['language', 'user'];

  /** * Tests for PluginNotFoundException. */
  public function testLanguageNegotiatorNoPlugin() {
    $logger = new BufferingLogger();
    $logger_factory = $this->createMock(LoggerChannelFactory::class);
    $logger_factory->expects($this->once())
      ->method('get')
      ->with('language')
      ->willReturn($logger);
    $this->container->set('logger.factory', $logger_factory);
    $this->installEntitySchema('user');

    // Test unavailable plugin.     $config = $this->config('language.types');
    $config->set('configurable', [LanguageInterface::TYPE_URL]);
    
 elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
            // CLI - display errors only if they're not already logged to STDERR             ini_set('display_errors', 1);
        }

        @ini_set('zend.assertions', 1);
        ini_set('assert.active', 1);
        ini_set('assert.exception', 1);

        DebugClassLoader::enable();

        return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
    }
}
 elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
            // CLI - display errors only if they're not already logged to STDERR             ini_set('display_errors', 1);
        }

        @ini_set('zend.assertions', 1);
        ini_set('assert.active', 1);
        ini_set('assert.exception', 1);

        DebugClassLoader::enable();

        return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
    }
}
Home | Imprint | This part of the site doesn't use cookies.