Skip to content

Commit 6ba98a0

Browse files
committed
Resque.logger accessor
1 parent 052d7a8 commit 6ba98a0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/resque.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'logger'
12
require 'redis/namespace'
23

34
require 'resque/version'
@@ -66,6 +67,9 @@ def redis_id
6667
end
6768
end
6869

70+
# Set or retrieve the current logger object
71+
attr_accessor :logger
72+
6973
# The `before_first_fork` hook will be run in the **parent** process
7074
# only once, before forking to run the first job. Be careful- any
7175
# changes you make will be permanent for the lifespan of the
@@ -369,3 +373,5 @@ def keys
369373
end
370374
end
371375

376+
# Log to STDOUT by default
377+
Resque.logger = Logger.new(STDOUT)

test/logger_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'test_helper'
2+
3+
context "Resque.logger" do
4+
test "sets and receives the active logger" do
5+
my_logger = Object.new
6+
Resque.logger = my_logger
7+
assert_equal my_logger, Resque.logger
8+
end
9+
end

0 commit comments

Comments
 (0)