simple_job 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/lib/simple_job/job_definition.rb +45 -0
- data/lib/simple_job/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
= Simple Job
|
2
2
|
|
3
|
+
== Version 0.6.0
|
4
|
+
* Added #logger method to classes that include JobDefinition and instances of that class; it returns a logger wrapper that:
|
5
|
+
* Wraps and uses JobQueue.config[:logger]
|
6
|
+
* Behaves identically to a standard Logger instance
|
7
|
+
* Will specify a progname of the definitions #type when none is explicitly stated
|
8
|
+
|
3
9
|
== Version 0.5.4
|
4
10
|
* Requiring aws-sdk in SQSJobQueue
|
5
11
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'logger'
|
1
2
|
require 'active_model'
|
2
3
|
require 'active_support/inflector'
|
3
4
|
|
@@ -127,8 +128,48 @@ module JobDefinition
|
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
131
|
+
def logger
|
132
|
+
self.class.logger
|
133
|
+
end
|
134
|
+
|
130
135
|
private
|
131
136
|
|
137
|
+
class JobLoggerWrapper
|
138
|
+
|
139
|
+
def initialize(logger, job_name)
|
140
|
+
@logger = logger
|
141
|
+
@job_name = job_name
|
142
|
+
end
|
143
|
+
|
144
|
+
def method_missing(symbol, *args, &block)
|
145
|
+
@logger.send symbol, *args, &block
|
146
|
+
end
|
147
|
+
|
148
|
+
def add(severity, message = nil, progname = nil, &block)
|
149
|
+
if message.nil? && !block_given?
|
150
|
+
message = progname
|
151
|
+
progname = nil
|
152
|
+
end
|
153
|
+
|
154
|
+
progname ||= @job_name
|
155
|
+
|
156
|
+
@logger.add(severity, message, progname, &block)
|
157
|
+
end
|
158
|
+
|
159
|
+
alias :log :add
|
160
|
+
|
161
|
+
[
|
162
|
+
['debug', Logger::DEBUG],
|
163
|
+
['info', Logger::INFO],
|
164
|
+
['warn', Logger::WARN],
|
165
|
+
['error', Logger::ERROR],
|
166
|
+
['fatal', Logger::FATAL]
|
167
|
+
].each do |method_name, log_level|
|
168
|
+
class_eval "def #{method_name}(progname = nil, &block); add(#{log_level}, nil, progname, &block); end"
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
132
173
|
module ClassMethods
|
133
174
|
|
134
175
|
def definition
|
@@ -195,6 +236,10 @@ module JobDefinition
|
|
195
236
|
end
|
196
237
|
end
|
197
238
|
|
239
|
+
def logger
|
240
|
+
@logger ||= JobLoggerWrapper.new(SimpleJob::JobQueue.config[:logger], definition[:type])
|
241
|
+
end
|
242
|
+
|
198
243
|
end
|
199
244
|
|
200
245
|
end
|
data/lib/simple_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dawson
|