creeper 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -235,7 +235,9 @@ module Creeper
235
235
 
236
236
  def error_work(worker, data, name, job)
237
237
  (worker.stopped_at = Time.now).tap do |stopped_at|
238
- Logger.error "#{worker.prefix} Error in #{worker.time_in_milliseconds}ms #{worker.dump(job, name, data)}"
238
+ error_message = "#{worker.prefix} Error after #{worker.time_in_milliseconds}ms #{worker.dump(job, name, data)}"
239
+ ErrorLogger.error error_message
240
+ Logger.error error_message
239
241
  end
240
242
  end
241
243
 
@@ -262,7 +264,7 @@ module Creeper
262
264
 
263
265
  def start_work(worker, data, name, job)
264
266
  (worker.started_at = Time.now).tap do |started_at|
265
- Logger.info "#{worker.prefix} Working #{Thread.list.count} #{worker.dump(job, name, data)}"
267
+ Logger.info "#{worker.prefix} Working #{worker.dump(job, name, data)}"
266
268
  end
267
269
  end
268
270
 
@@ -404,5 +406,6 @@ module Creeper
404
406
 
405
407
  end
406
408
 
407
- # require 'creeper/creep'
409
+ require 'creeper/creep'
410
+ require 'creeper/error_logger'
408
411
  require 'creeper/logger'
@@ -0,0 +1,37 @@
1
+ module Creeper
2
+ module ErrorLogger
3
+ module_function
4
+
5
+ # Send a debug message
6
+ def debug(string)
7
+ Creeper.error_logger.debug(string) if Creeper.error_logger
8
+ end
9
+
10
+ # Send a info message
11
+ def info(string)
12
+ Creeper.error_logger.info(string) if Creeper.error_logger
13
+ end
14
+
15
+ # Send a warning message
16
+ def warn(string)
17
+ Creeper.error_logger.warn(string) if Creeper.error_logger
18
+ end
19
+
20
+ # Send an error message
21
+ def error(string)
22
+ Creeper.error_logger.error(string) if Creeper.error_logger
23
+ end
24
+
25
+ # Handle a crash
26
+ def crash(string, exception)
27
+ string << "\n" << format_exception(exception)
28
+ error string
29
+ end
30
+
31
+ # Format an exception message
32
+ def format_exception(exception)
33
+ str = "#{exception.class}: #{exception.to_s}\n"
34
+ str << exception.backtrace.join("\n")
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Creeper
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -129,6 +129,7 @@ files:
129
129
  - lib/creeper.rb
130
130
  - lib/creeper/celluloid_ext.rb
131
131
  - lib/creeper/creep.rb
132
+ - lib/creeper/error_logger.rb
132
133
  - lib/creeper/launcher.rb
133
134
  - lib/creeper/logger.rb
134
135
  - lib/creeper/version.rb