Class: Nightwatch::ExceptionManager
- Inherits:
-
Object
- Object
- Nightwatch::ExceptionManager
- Includes:
- Singleton
- 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.
18 19 20 21 |
# File 'lib/nightwatch/monitor.rb', line 18 def initialize @exceptions = {} @config = Configuration.instance end |
Class Method Details
.absolute_path(file) ⇒ Object
11 12 13 |
# File 'lib/nightwatch/monitor.rb', line 11 def self.absolute_path(file) File.absolute_path(file).gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR) end |
Instance Method Details
#add_exception(exception) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nightwatch/monitor.rb', line 23 def add_exception(exception) Configuration.instance.filters.each do |filter| exception = filter.apply(exception) break if !exception end if exception @exceptions[exception.object_id] = [exception, stack(exception), Time.now.to_i] end end |
#commit! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/nightwatch/monitor.rb', line 34 def commit! host = Socket.gethostname env = Hash[ENV.to_a] @exceptions.each do |id, info| exception, stack, ticks = info klass = exception.class.name record = { class: klass, message: exception.to_s, script: @@script, argv: @@argv, pid: $$, env: env, config: RbConfig::CONFIG, host: host, stack: stack, timestamp: ticks } @config.logger.log(record) end end |