Sha256: 925ad225f10426a92cf95ad8b174cb02ba539062663319ce855b35281069f6f5

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
telegram-bot-0.16.5 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.16.4 lib/telegram/bot/updates_controller/log_subscriber.rb
telegram-bot-0.16.3 lib/telegram/bot/updates_controller/log_subscriber.rb