Skip to content

Commit 1c46db9

Browse files
committed
Rename Resque::Logger to Resque::Logging
Having both Resque.logger (which expects and stdlib Logger duck type) and Resque::Logger is confusing. Resque::Logging is a module that can be added to any class that wants logging functionality. Giving it a slightly different name helps disambiguate. In addition, this gets rid of Resque::Logging#__log__ in favor of a class method. Boo underscore methods!
1 parent 5a50b7a commit 1c46db9

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

lib/resque.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
require 'resque/helpers'
1212
require 'resque/stat'
13-
require 'resque/logger'
13+
require 'resque/logging'
1414
require 'resque/job'
1515
require 'resque/worker'
1616
require 'resque/plugin'

lib/resque/logger.rb

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/resque/logging.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Resque
2+
# Include this module in classes you wish to have logging facilities
3+
module Logging
4+
module_function
5+
6+
# Thunk to the logger's own log method (if configured)
7+
def self.log(severity, message)
8+
Resque.logger.__send__(severity, message) if Resque.logger
9+
end
10+
11+
# Log level aliases
12+
def debug(message); Logging.log :debug, message; end
13+
def info(message); Logging.log :info, message; end
14+
def warn(message); Logging.log :warn, message; end
15+
def error(message); Logging.log :error, message; end
16+
def fatal(message); Logging.log :fatal, message; end
17+
end
18+
end

lib/resque/worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Resque
99
class Worker
1010
extend Resque::Helpers
1111
include Resque::Helpers
12-
include Resque::Logger
12+
include Resque::Logging
1313

1414
# Whether the worker should log basic info to STDOUT
1515
attr_accessor :verbose

test/logger_test.rb renamed to test/logging_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'test_helper'
22
require 'minitest/mock'
33

4-
context "Resque::Logger" do
4+
context "Resque::Logging" do
55
teardown { reset_logger }
66

77
test "sets and receives the active logger" do
@@ -17,7 +17,7 @@
1717
mock_logger.expect severity.to_sym, nil, [message]
1818
Resque.logger = mock_logger
1919

20-
Resque::Logger.send severity, message
20+
Resque::Logging.send severity, message
2121
mock_logger.verify
2222
end
2323
end

0 commit comments

Comments
 (0)