Sha256: 5d65b588ae940501335728d6ef780d5f3341bf0b9d252cd20afb781dc0c9d001

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'active_support/log_subscriber'

module Proscenium
  class LogSubscriber < ActiveSupport::LogSubscriber
    def sideload(event)
      info do
        "  [Proscenium] Side loaded #{event.payload[:identifier]}"
      end
    end

    def build_to_path(event)
      path = event.payload[:identifier]
      cached = event.payload[:cached] ? ' | Cached!' : ''
      path = CGI.unescape(path) if path.start_with?(/https?%3A%2F%2F/)

      info do
        message = "  #{color('[Proscenium]', nil, bold: true)} Building (to path) #{path}"
        message << " (Duration: #{event.duration.round(1)}ms | " \
                   "Allocations: #{event.allocations}#{cached})"
      end
    end

    def build_to_string(event)
      path = event.payload[:identifier]
      path = CGI.unescape(path) if path.start_with?(/https?%3A%2F%2F/)

      info do
        message = "  #{color('[Proscenium]', nil, bold: true)} Building #{path}"
        message << " (Duration: #{event.duration.round(1)}ms | Allocations: #{event.allocations})"
      end
    end
  end
end

Proscenium::LogSubscriber.attach_to :proscenium

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
proscenium-0.18.0-x86_64-linux lib/proscenium/log_subscriber.rb
proscenium-0.18.0-aarch64-linux lib/proscenium/log_subscriber.rb
proscenium-0.18.0-arm64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.18.0-x86_64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.17.0-x86_64-linux lib/proscenium/log_subscriber.rb
proscenium-0.17.0-aarch64-linux lib/proscenium/log_subscriber.rb
proscenium-0.17.0-arm64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.17.0-x86_64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.16.0-aarch64-linux lib/proscenium/log_subscriber.rb
proscenium-0.16.0-arm64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.16.0-x86_64-darwin lib/proscenium/log_subscriber.rb
proscenium-0.16.0 lib/proscenium/log_subscriber.rb