Class: ExceptionManager
- Inherits:
-
Object
- Object
- ExceptionManager
- Defined in:
- lib/nightwatch/monitor.rb
Constant Summary collapse
- @@argv =
Array.new(ARGV)
- @@script =
absolute_path($0)
Class Method Summary collapse
Instance Method Summary collapse
- #add_exception(exception) ⇒ Object
- #commit! ⇒ Object
-
#initialize ⇒ ExceptionManager
constructor
A new instance of ExceptionManager.
Constructor Details
#initialize ⇒ ExceptionManager
Returns a new instance of ExceptionManager.
16 17 18 |
# File 'lib/nightwatch/monitor.rb', line 16 def initialize @exceptions = {} end |
Class Method Details
.absolute_path(file) ⇒ Object
9 10 11 |
# File 'lib/nightwatch/monitor.rb', line 9 def self.absolute_path(file) File.absolute_path(file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR) end |
.instance ⇒ Object
5 6 7 |
# File 'lib/nightwatch/monitor.rb', line 5 def self.instance @@manager ||= ExceptionManager.new end |
Instance Method Details
#add_exception(exception) ⇒ Object
20 21 22 |
# File 'lib/nightwatch/monitor.rb', line 20 def add_exception(exception) @exceptions[exception.object_id] = [exception, stack(exception), Time.now.to_i] end |
#commit! ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nightwatch/monitor.rb', line 24 def commit! # Support other connection endpoints mongo = Mongo::MongoClient.new collection = mongo['nightwatch']['exceptions'] host = Socket.gethostname env = Hash[ENV.to_a] @exceptions.each do |id, info| exception, stack, ticks = info klass = exception.class.name collection.insert({ pid: $$, script: @@script, argv: @@argv, env: env, host: host, class: klass, message: exception.to_s, stack: stack, timestamp: ticks }) end end |