Skip to content

Commit

Permalink
fix: включение логирования в джобах
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBochkarev committed Jan 25, 2018
1 parent 27b7b31 commit 927f57e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/resque/integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require 'resque'
silence_warnings { require 'resque/plugins/meta' }

require 'resque/integration/monkey_patch/verbose_formatter'
require 'resque/integration/hooks'

require 'resque/scheduler'
Expand Down
10 changes: 10 additions & 0 deletions lib/resque/integration/monkey_patch/verbose_formatter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "resque/log_formatters/verbose_formatter"

module Resque
class VerboseFormatter
def call(serverity, datetime, progname, msg)
time = Time.now.strftime('%H:%M:%S %Y-%m-%d')
"** [#{time}] #$$: #{msg}\n"
end
end
end
3 changes: 3 additions & 0 deletions lib/resque/integration/tasks/hooks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace :resque do
# (rails 3 не делают этого при запуске из rake-задачи)
Rails.application.eager_load! if Rails::VERSION::MAJOR < 4

# Включаем логирование в resque
ENV['VERBOSE'] = '1'

# перенаправление вывода в файл
Resque::Integration::LogsRotator.redirect_std
# слушать HUP сигнал для ротации логов
Expand Down

0 comments on commit 927f57e

Please sign in to comment.