Sha256: cc5819ef0c06d3e4b5be641d43e1ba371a8c769a0aa7017a27d7aeebb7d42f9b
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
require 'logger' module Backburner module Logger # Loads in instance and class levels def self.included(base) base.extend self end # Print out when a job is about to begin def log_job_begin(name, args) log_info "Work job #{name} with #{args.inspect}" @job_started_at = Time.now end # Print out when a job completed def log_job_end(name, message = nil) ellapsed = Time.now - job_started_at ms = (ellapsed.to_f * 1000).to_i log_info("Finished #{name} in #{ms}ms #{message}") end # Returns true if the job logging started def job_started_at @job_started_at end # Print a message to stdout # # @example # log_info("Working on task") # def log_info(msg) logger ? logger.info(msg) : puts(msg) end # Print an error to stderr # # @example # log_error("Task failed!") # def log_error(msg) logger ? logger.error(msg) : $stderr.puts(msg) end # Return logger if specified def logger Backburner.configuration.logger end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
backburner-0.2.6 | lib/backburner/logger.rb |
backburner-0.2.5 | lib/backburner/logger.rb |
backburner-0.2.0 | lib/backburner/logger.rb |
backburner-0.1.2 | lib/backburner/logger.rb |