[GH-ISSUE #513] FirePHPHandler bubles errors and ChromePHPHandler disable FirePHPHandler #180

Closed
opened 2026-03-04 02:12:54 +03:00 by kerem · 2 comments
Owner

Originally created by @BlackScorp on GitHub (Feb 25, 2015).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/513

Hello everyone,

maybe i didn't understood what bubbling means, but following code display all log messages in firebug console

$logger = new Monolog\Logger($channelName);
$firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false);
$logger->pushHandler($firePHPHandler);
$logger->debug('Test Debug');
$logger->info('test info');
$logger->info('test info');
$logger->info('test info');
$logger->warning('test warning');

but i expected to see only debug message, in my code i use info and warning logs with different handler and the debug schould be a replacement for var_dump

maybe i used it wrong?

also if i add ChromePHPHandler

$logger = new Monolog\Logger($channelName);
$firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false);
$logger->pushHandler($firePHPHandler);
$chromePHPHandler = new \Monolog\Handler\ChromePHPHandler(Psr\Log\LogLevel::DEBUG,false);
$logger->pushHandler($chromePHPHandler);
$logger->debug('Test Debug');
$logger->info('test info');
$logger->info('test info');
$logger->info('test info');
$logger->warning('test warning');

there are no logs anymore in FirePHP Console, only in ChromePHP, however if i add the chrome handler to buffer handler

$logger = new Monolog\Logger($channelName);
$firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false);
$logger->pushHandler($firePHPHandler);
$chromePHPHandler = new \Monolog\Handler\ChromePHPHandler(Psr\Log\LogLevel::DEBUG,false);
$logger->pushHandler(new \Monolog\Handler\BufferHandler($chromePHPHandler));
$logger->debug('Test Debug');
$logger->info('test info');
$logger->info('test info');
$logger->info('test info');
$logger->warning('test warning');

then i see the log messages in Chrome and Firefox but still all messages are displayed, while bubbling is deaktivated.

is this a real bug? or just wrong usage?

Cheers

Originally created by @BlackScorp on GitHub (Feb 25, 2015). Original GitHub issue: https://github.com/Seldaek/monolog/issues/513 Hello everyone, maybe i didn't understood what bubbling means, but following code display all log messages in firebug console ``` php $logger = new Monolog\Logger($channelName); $firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false); $logger->pushHandler($firePHPHandler); $logger->debug('Test Debug'); $logger->info('test info'); $logger->info('test info'); $logger->info('test info'); $logger->warning('test warning'); ``` but i expected to see only debug message, in my code i use info and warning logs with different handler and the debug schould be a replacement for var_dump maybe i used it wrong? also if i add ChromePHPHandler ``` PHP $logger = new Monolog\Logger($channelName); $firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false); $logger->pushHandler($firePHPHandler); $chromePHPHandler = new \Monolog\Handler\ChromePHPHandler(Psr\Log\LogLevel::DEBUG,false); $logger->pushHandler($chromePHPHandler); $logger->debug('Test Debug'); $logger->info('test info'); $logger->info('test info'); $logger->info('test info'); $logger->warning('test warning'); ``` there are no logs anymore in FirePHP Console, only in ChromePHP, however if i add the chrome handler to buffer handler ``` PHP $logger = new Monolog\Logger($channelName); $firePHPHandler = new \Monolog\Handler\FirePHPHandler(Psr\Log\LogLevel::DEBUG,false); $logger->pushHandler($firePHPHandler); $chromePHPHandler = new \Monolog\Handler\ChromePHPHandler(Psr\Log\LogLevel::DEBUG,false); $logger->pushHandler(new \Monolog\Handler\BufferHandler($chromePHPHandler)); $logger->debug('Test Debug'); $logger->info('test info'); $logger->info('test info'); $logger->info('test info'); $logger->warning('test warning'); ``` then i see the log messages in Chrome and Firefox but still all messages are displayed, while bubbling is deaktivated. is this a real bug? or just wrong usage? Cheers
kerem closed this issue 2026-03-04 02:12:54 +03:00
Author
Owner

@stof commented on GitHub (Feb 25, 2015):

Well, given you pushed a ChromephpHandler on the stack and it disables bubbling, no messages will go to the next handler in the stack. So it is expected that firefox does not receive log messages anymore.
when you use the BufferHandler, you see logs in firefox because the BufferHandler itself allows bubbling in your code.

And the level they accept is the min level for which they handle messages. Setting the level to debug will accept anything.

If you want to display only debug messages in chrome and firefox, there is 2 solutions:

  • push the handler for the Info+ level after the chrome and firefox handlers (so that it is first in the stack) and prevent bubbling in this one (so that Info+ messages are stopped before reaching these browser handlers but debug messages go through as they are not handled)
  • wrap the firefox and chrome handlers in a FilterHandler accepting only debug messages (and don't change the message bubbling at all)
<!-- gh-comment-id:75941755 --> @stof commented on GitHub (Feb 25, 2015): Well, given you pushed a ChromephpHandler on the stack and it disables bubbling, no messages will go to the next handler in the stack. So it is expected that firefox does not receive log messages anymore. when you use the BufferHandler, you see logs in firefox because the BufferHandler itself allows bubbling in your code. And the level they accept is the **min** level for which they handle messages. Setting the level to debug will accept anything. If you want to display only debug messages in chrome and firefox, there is 2 solutions: - push the handler for the Info+ level _after_ the chrome and firefox handlers (so that it is first in the stack) and prevent bubbling in this one (so that Info+ messages are stopped before reaching these browser handlers but debug messages go through as they are not handled) - wrap the firefox and chrome handlers in a FilterHandler accepting _only_ debug messages (and don't change the message bubbling at all)
Author
Owner

@BlackScorp commented on GitHub (Feb 25, 2015):

@stof thanks, everything is working now so it was a bad usage after all

<!-- gh-comment-id:75949026 --> @BlackScorp commented on GitHub (Feb 25, 2015): @stof thanks, everything is working now so it was a bad usage after all
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#180
No description provided.