averell23-watchdogger 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/dog_log.rb CHANGED
@@ -9,12 +9,14 @@ class DogLog # :nodoc:
9
9
  # but should not usually be called on an active log.
10
10
  def setup(logfile, severity)
11
11
  @logfile = logfile
12
- @severity = Logger.const_get(severity.upcase)
12
+ @severity = severity.is_a?(Fixnum) ? severity : Logger.const_get(severity.upcase)
13
13
  if(@logger)
14
14
  assit_fail('Resetting logfile')
15
15
  @logger.close if(@logger.respond_to?(:close))
16
16
  @logger = nil
17
17
  end
18
+ rescue NameError => e
19
+ raise(NameError, "Problems setting the log level: #{severity} (#{e.message})")
18
20
  end
19
21
 
20
22
  # If nothing is configured, we log to STDERR by default
data/lib/watcher/base.rb CHANGED
@@ -69,7 +69,7 @@ module Watcher
69
69
  run_actions(event)
70
70
  @current_severity = 0
71
71
  else
72
- warn_actions(event)
72
+ run_warn_actions(event)
73
73
  end
74
74
 
75
75
  @last_run = Time.now
@@ -80,7 +80,7 @@ module Watcher
80
80
  actions.each { |ac| WatcherAction.run_action(ac, event) }
81
81
  end
82
82
 
83
- def warn_actions(event)
83
+ def run_warn_actions(event)
84
84
  warn_actions.each { |ac| WatcherAction.run_action(ac, event) }
85
85
  end
86
86
 
@@ -73,6 +73,18 @@ class WatchdoggerTest < Test::Unit::TestCase
73
73
  assert_equal(true, action_status('default'))
74
74
  end
75
75
 
76
+ def test_warn_actions
77
+ WatcherAction.register('default-warn', { :type => 'dummy_action' })
78
+ assert_equal(nil, action_status('default'))
79
+ assert_equal(nil, action_status('default-warn'))
80
+ Watcher.register('dummy2', { 'type' => :dummy_watcher, 'actions' => :default, 'warn_actions' => 'default-warn', :watchit => 'Fail' , :severity => '50' })
81
+ Watcher.watch_all!
82
+ assert_equal(true, action_status('default-warn'))
83
+ assert_equal(nil, action_status('default'))
84
+ Watcher.watch_all!
85
+ assert_equal(true, action_status('default'))
86
+ end
87
+
76
88
  private
77
89
 
78
90
  def action_status(name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: averell23-watchdogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Hahn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-16 00:00:00 -07:00
12
+ date: 2009-07-17 00:00:00 -07:00
13
13
  default_executable: watchdogger
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency