symfony / monolog-bundle

Symfony Monolog Bundle
symfony.com
MIT License
2.89k stars 230 forks source link

Level is not being read from config for custom handler #322

Open mattdillon100 opened 5 years ago

mattdillon100 commented 5 years ago

I have created a custom handler to push logs to AWS Firehose. Here is the constructor:

class FirehoseLogHandler extends AbstractProcessingHandler {

public function __construct(
        FirehoseClient $firehoseClient,
        FormatterInterface $formatter,
        $streamName,
        $level = Logger::INFO,
        $bubble = true
    ) {

        $this->firehoseClient = $firehoseClient;
        $this->streamName = $streamName;
        $this->formatter = $formatter;

        parent::__construct($level, $bubble);
    }

And here is my monolog.yaml config:

monolog:
  handlers:
    firehose_handler:
      type: service
      id: kinesis_stream_handler

    main:
      type: stream
      handler: firehose_handler
      level: error
      channels: ["!event"]

services:
  kinesis_stream_handler:
    class: App\Logger\Handler\FirehoseLogHandler
    arguments:
      $firehoseClient: '@aws.firehose'
      $formatter: '@App\Logger\Formatter\FirehoseLogFormatter'
      $streamName: 'firehose-stream-test'

The problem that I am having is that the $level is always set to Logger::INFO (200), or whatever is set in the constructor. It seems to be ignoring what is set in the yaml config

kufd commented 5 years ago

It seems that the issue is the same as https://github.com/getsentry/sentry-symfony/issues/229

mattdillon100 commented 5 years ago

@kufd you're absolutely correct. Will close this one.

kufd commented 5 years ago

@wildcard27 you should not close your issue. Because the issue I mentioned is already closed. I did my comment just for folks who have the same problem with sentry logger and need to know when it is fixed

mattdillon100 commented 5 years ago

Good point. I've reopened. I'm working on a PR so will attach it to this ticket when created.