U
U
u3830382021-04-09 13:10:19
symfony
u383038, 2021-04-09 13:10:19

How to add telegram handler to monologue via bundles in Symfony?

Integration with slack in the monologue for logging is screwed into the project, you need to change it to telegram. In a normal monologue, it turned out to make and run TelegramBotHandler. In the bundles in symphony, I can’t figure out how to do this. Please tell

monolog.yaml

monolog:
    handlers:
        filter_for_errors:
            type: fingers_crossed
            # if *one* log is error or higher, pass *all* to file_log
            action_level: NOTICE
            handler: grouped

        grouped:
            type: group
            members: [main, message]

        main:
            type: stream
            path: "php://stderr"
            formatter: monolog.formatter.dc_formatter

        message:
            type: slack
            token: '%env(lsSLACK_TOKEN)%'
            channel: '%env(SLACK_CHANNEL)%'
            bot_name: 'CS Partner'
            level: warning
            include_extra: true

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2021-04-09
@u383038

# servces.yaml
services:
    Monolog\Handler\TelegramBotHandler:
        arguments:
            - '%env(TELEGRAM_BOT_KEY)%'
            - '%env(TELEGRAM_CHANNEL)%'

# monolog.yaml
monolog:
    handlers:
        message:
            type: fingers_crossed
            action_level: error
            excluded_http_codes: [ 400, 401, 403, 404 ]
            buffer_size: 50
            handler: deduplicated
        deduplicated:
            type: deduplication
            handler: telegram
        telegram: # Важна только эта часть
            type: service
            id: Monolog\Handler\TelegramBotHandler
            level: debug

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question