rollbar-php-symfony-bundle icon indicating copy to clipboard operation
rollbar-php-symfony-bundle copied to clipboard

Why the minimum level of reporting is set to ERROR?

Open jantenuccigsbla opened this issue 5 years ago • 2 comments

Hi All! I need to send Debug & Info messages through this bundle (Its possible to do it with the SDK of rollbar)

But in the RollBarHandlerFactory of this bundle set the minimum level in ERROR. It means that i cant send any event below error level (ie info / debug levels) So $logger->info('INFO MESSAGE') wont work :S

See the code /** * Create RollbarHandler * * @return RollbarHandler */ public function createRollbarHandler() { return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); }

Any suggestions? Thanks a lot

jantenuccigsbla avatar Nov 14 '19 20:11 jantenuccigsbla

Yes, it's easy:

  1. Drop dependency on this bundle and use only composer require rollbar/rollbar:^2.0
  2. Add to config/services.yaml:
parameters:
    rollbar.config:
        access_token: 'your_access_token'
        environment: 'your_environment'
        code_version: 'your_code_version'
        allow_exec: false
        exception_sample_rates:
            Symfony\Component\HttpKernel\Exception\HttpException: 0
        # any other options available in https://docs.rollbar.com/docs/php-configuration-reference

services:
    App\Logger\Handler\RollbarHandlerFactory:
        $config: '%rollbar.config%'

    Rollbar\Monolog\Handler\RollbarHandler:
        factory: ['@App\Logger\Handler\RollbarHandlerFactory', createRollbarHandler]
        tags:
            - { name: monolog.logger, channel: rollbar }
  1. Create App\Logger\Handler\RollbarHandlerFactory class:
<?php

namespace App\Logger\Handler;

use Psr\Log\LogLevel;
use Rollbar\Monolog\Handler\RollbarHandler;
use Rollbar\Rollbar;

class RollbarHandlerFactory
{
    public function __construct(array $config)
    {
        Rollbar::init($config, false, false, false);
    }

    public function createRollbarHandler(): RollbarHandler
    {
        return new RollbarHandler(Rollbar::logger(), LogLevel::INFO);
    }
}
  1. Enjoy and don't wait for years until new features from Rollbar library itself appear in this bundle.

javer avatar May 22 '20 13:05 javer

Just been trying to figure out why Symfony's fingers_crossed Handler wrapper wasn't working with this. Commenting so this might come up if people search for Symfony fingers crossed for Rollbar.

Is there any chance this will be fixed, or a PR accepted/tagged?

glennmcewan avatar Mar 01 '21 21:03 glennmcewan