Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from cristianbica/logging
Added logging capabilities
- Loading branch information
Showing
4 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
require 'active_job/queue_adapter' | ||
require 'active_job/queue_name' | ||
require 'active_job/enqueuing' | ||
require 'active_job/logging' | ||
|
||
module ActiveJob | ||
class Base | ||
extend QueueAdapter | ||
extend QueueName | ||
extend Enqueuing | ||
extend Logging | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module ActiveJob | ||
class LogSubscriber < ActiveSupport::LogSubscriber | ||
def enqueue(event) | ||
payload = event.payload | ||
params = payload[:params] | ||
adapter = payload[:adapter] | ||
job = payload[:job] | ||
|
||
info "ActiveJob enqueued to #{adapter.name.demodulize} job #{job.name}: #{params.inspect}" | ||
end | ||
|
||
def logger | ||
ActiveJob::Base.logger | ||
end | ||
end | ||
end | ||
|
||
ActiveJob::LogSubscriber.attach_to :active_job |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'active_job/log_subscriber' | ||
|
||
module ActiveJob | ||
module Logging | ||
mattr_accessor(:logger) { ActiveSupport::Logger.new(STDOUT) } | ||
end | ||
end |