Sha256: 8fe5ca8262063d81ae8224fc3b96296d8ce9a2f4077fa68ca877674fceeb18c7

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true
class Coursemology::Evaluator::Logging::DockerLogSubscriber < ActiveSupport::LogSubscriber
  def pull(event)
    cached = event.payload[:cached].nil? || event.payload[:cached] ? 'Cached ' : ''
    header_colour = cached ? GREEN : YELLOW
    info "#{color("#{cached}Docker Pull (#{event.duration.round(1)}ms)", header_colour)} "\
      "#{event.payload[:image]}"
  end

  def create(event)
    info "#{color("Docker Create (#{event.duration.round(1)}ms)", MAGENTA)} "\
      "#{event.payload[:image]} => #{event.payload[:container].id}"
  end

  def destroy(event)
    info "#{color("Docker Destroy (#{event.duration.round(1)}ms)", CYAN)} "\
      "#{event.payload[:container]}"
  end
end

Coursemology::Evaluator::Logging::DockerLogSubscriber.attach_to(:'docker.evaluator.coursemology')

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coursemology-evaluator-0.1.6 lib/coursemology/evaluator/logging/docker_log_subscriber.rb
coursemology-evaluator-0.1.4 lib/coursemology/evaluator/logging/docker_log_subscriber.rb