1
0
зеркало из https://github.com/glebtv/telegram-bot.git synced 2026-08-28 15:26:18 +03:00
Files
telegram-bot/lib/telegram/bot/updates_controller/log_subscriber.rb
Max Melentiev 57b17f068c Update rubopcop (#227)
* Update rubopcop [WIP]

* Further rubocop fixes

* Fix rubocop-rails cops

* Fix spec

* Disable rubocop suggestions

* Run rubocop in github actions rather than in codeclimate
2023-12-30 15:20:27 +00:00

41 строка
1.1 KiB
Ruby

# frozen_string_literal: true
require 'active_support/log_subscriber'
module Telegram
module Bot
class UpdatesController
class LogSubscriber < ActiveSupport::LogSubscriber
def start_processing(event)
info do
payload = event.payload
"Processing by #{payload[:controller]}##{payload[:action]}\n" \
" Update: #{payload[:update].to_json}"
end
end
def process_action(event)
info do
payload = event.payload
additions = UpdatesController.log_process_action(payload)
message = "Completed in #{event.duration.round}ms"
message << " (#{additions.join(' | ')})" if additions.present?
message
end
end
def respond_with(event)
info { "Responded with #{event.payload[:type]}" }
end
def halted_callback(event)
info { "Filter chain halted at #{event.payload[:filter].inspect}" }
end
delegate :logger, to: UpdatesController
attach_to 'updates_controller.bot.telegram'
end
end
end
end