Sha256: edf1e7d5fb179acbda9efdb3dd6eb38f5a8b210023a55ccfb9f714c31753df3d

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

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(' | ')})" unless additions.blank?
            message
          end
        end

        def reply_with(event)
          info { "Replied 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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
telegram-bot-0.7.4 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.7.3 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.7.2 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.6.0 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.5.0 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.4.2 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.4.1 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.4.0 lib/telegram/bot/updates_controller/log_subscriber.rb