class Sidekiq::History::LogParser

Heroku have read only file system. See more in this link: devcenter.heroku.com/articles/read-only-filesystem

Public Class Methods

new(worker_name) click to toggle source
# File lib/sidekiq/history/log_parser.rb, line 6
def initialize(worker_name)
  @worker_name = worker_name
  @logfile = log_file
end

Public Instance Methods

color(line) click to toggle source
# File lib/sidekiq/history/log_parser.rb, line 23
def color(line)
  case
  when line.include?('done') then 'green'
  when line.include?('start') then 'yellow'
  when line.include?('fail') then 'red'
  end
end
line_hash(line) click to toggle source
# File lib/sidekiq/history/log_parser.rb, line 19
def line_hash(line)
  { color: color(line), text: line.sub(/\n/, '') }
end
parse() click to toggle source
# File lib/sidekiq/history/log_parser.rb, line 11
def parse
  return [] unless File.exists?(@logfile)

  File.open(@logfile).map do |line|
    line_hash(line) if line[/\W?#@worker_name\W?/]
  end.compact
end

Private Instance Methods

log_file() click to toggle source
# File lib/sidekiq/history/log_parser.rb, line 32
def log_file
  Sidekiq.options[:logfile] || Sidekiq::History.configuration.log_file
end