[GH-ISSUE #902] Slackhandler, cannot simply display the message #355

Closed
opened 2026-03-04 02:14:23 +03:00 by kerem · 0 comments
Owner

Originally created by @riccardomessineo on GitHub (Dec 12, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/902

Hi,
I've already posted a PR to fix this problem but with the new release my changes were overwritten (issue #871 and PR #872).
I want the SlackHandler to print the simple message, without formatting anything (I've already set the processors to do that).

By this settings:

        $slackInfoHandler = new \Monolog\Handler\SlackHandler($slackToken, $infoChannel, 'Swite API Logger', true, $slackEmoji, $infoLevel, $infoBubble, false, true);
        $slackInfoHandler->pushProcessor(new \Monolog\Processor\WebProcessor);
        $slackInfoHandler->pushProcessor(new \Monolog\Processor\IntrospectionProcessor);
        $monolog->pushHandler($slackInfoHandler);

I'm outputting this kind of errors:
schermata 2016-12-12 alle 16 06 51

I think the problem lies in this piece of code (SlackRecord):

        if ($this->formatter) {
            $message = $this->formatter->format($record);
        } else {
            $message = $record['message'];
        }

Because Formatter is always declared (code of SlackHandler):

    public function getFormatter()
    {
        $formatter = parent::getFormatter();
        $this->slackRecord->setFormatter($formatter);

        return $formatter;
    }
Originally created by @riccardomessineo on GitHub (Dec 12, 2016). Original GitHub issue: https://github.com/Seldaek/monolog/issues/902 Hi, I've already posted a PR to fix this problem but with the new release my changes were overwritten (issue #871 and PR #872). I want the SlackHandler to print the simple message, without formatting anything (I've already set the processors to do that). By this settings: ``` $slackInfoHandler = new \Monolog\Handler\SlackHandler($slackToken, $infoChannel, 'Swite API Logger', true, $slackEmoji, $infoLevel, $infoBubble, false, true); $slackInfoHandler->pushProcessor(new \Monolog\Processor\WebProcessor); $slackInfoHandler->pushProcessor(new \Monolog\Processor\IntrospectionProcessor); $monolog->pushHandler($slackInfoHandler); ``` I'm outputting this kind of errors: <img width="578" alt="schermata 2016-12-12 alle 16 06 51" src="https://cloud.githubusercontent.com/assets/10194398/21104001/1521429a-c085-11e6-98b9-1651d5a4f769.png"> I think the problem lies in this piece of code (SlackRecord): ``` if ($this->formatter) { $message = $this->formatter->format($record); } else { $message = $record['message']; } ``` Because Formatter is always declared (code of SlackHandler): ``` public function getFormatter() { $formatter = parent::getFormatter(); $this->slackRecord->setFormatter($formatter); return $formatter; } ```
kerem closed this issue 2026-03-04 02:14:23 +03:00
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#355
No description provided.