Sha256: 4a5c723daba0c2c9cabc6eadf17fe716cd3e1f08064e4020ad08f78def2956f4

Contents?: true

Size: 1.77 KB

Versions: 21

Compression:

Stored size: 1.77 KB

Contents

require "logger"

module CukeForker
  class LoggingListener < AbstractListener
    TIME_FORMAT = "%Y-%m-%d %H:%M:%S"

    def initialize(io = STDOUT)
      @io = io
    end

    def on_run_starting
      log.info "[    run           ] starting"
    end

    def on_worker_starting(worker)
      log.info "[    worker  #{worker.id.to_s.ljust 3}   ] starting: #{worker.feature}"
    end

    def on_worker_forked(worker)
      log.info "[    worker  #{worker.id.to_s.ljust 3}   ] forked  : #{worker.feature}"
    end

    def on_worker_finished(worker)
      log.info "[    worker  #{worker.id.to_s.ljust 3}   ] #{status_string(worker.failed?).ljust(8)}: #{worker.feature}"
    end

    def on_run_finished(failed)
      log.info "[    run           ] finished, #{status_string failed}"
    end

    def on_run_interrupted
      puts "\n"
      log.info "[    run           ] interrupted - please wait"
    end

    def on_display_fetched(server)
      log.info "[    display #{server.display.to_s.ljust(3)}   ] fetched"
    end

    def on_display_released(server)
      log.info "[    display #{server.display.to_s.ljust(3)}   ] released"
    end

    def on_display_starting(server)
      log.info "[    display #{server.display.to_s.ljust(3)}   ] starting"
    end

    def on_display_stopping(server)
      log.info "[    display #{server.display.to_s.ljust(3)}   ] stopping"
    end

    def on_eta(eta, remaining, finished)
      counts = "#{remaining}/#{finished}".ljust(6)
      log.info "[    eta     #{counts}] #{eta.strftime TIME_FORMAT}"
    end

    private

    def status_string(failed)
      failed ? 'failed' : 'passed'
    end

    def log
      @log ||= (
        log = Logger.new @io
        log.datetime_format = TIME_FORMAT

        log
      )
    end
  end # LoggingListener

end # CukeForker

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
cukeforker-1.0.0 lib/cukeforker/logging_listener.rb
cukeforker-0.2.5 lib/cukeforker/logging_listener.rb
cukeforker-0.2.4 lib/cukeforker/logging_listener.rb
cukeforker-0.2.3 lib/cukeforker/logging_listener.rb
cukeforker-0.2.2 lib/cukeforker/logging_listener.rb
cukeforker-0.2.1 lib/cukeforker/logging_listener.rb
cukeforker-0.2.0 lib/cukeforker/logging_listener.rb
cukeforker-0.1.9 lib/cukeforker/logging_listener.rb
cukeforker-0.1.8 lib/cukeforker/logging_listener.rb
cukeforker-0.1.7 lib/cukeforker/logging_listener.rb
cukeforker-0.1.6 lib/cukeforker/logging_listener.rb
cukeforker-0.1.5 lib/cukeforker/logging_listener.rb
cukeforker-0.1.4 lib/cukeforker/logging_listener.rb
cukeforker-0.1.3 lib/cukeforker/logging_listener.rb
cukeforker-0.1.2 lib/cukeforker/logging_listener.rb
cukeforker-0.1.1 lib/cukeforker/logging_listener.rb
cukeforker-0.1.0 lib/cukeforker/logging_listener.rb
cukeforker-0.0.9 lib/cukeforker/logging_listener.rb
cukeforker-0.0.8 lib/cukeforker/logging_listener.rb
cukeforker-0.0.7 lib/cukeforker/logging_listener.rb