simple_monitor 0.0.1 → 0.0.2
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/README.md +1 -1
- data/lib/simple_monitor/version.rb +1 -1
- data/lib/simple_monitor.rb +11 -2
- data/spec/simple_monitor_spec.rb +17 -0
- metadata +5 -5
data/README.md
CHANGED
@@ -50,7 +50,7 @@ monitor = HighJobMonitor.new(:job_count_threshold => 99)
|
|
50
50
|
monitor.check
|
51
51
|
```
|
52
52
|
|
53
|
-
For a typical application, it could be
|
53
|
+
For a typical application, it could be desirable to define an
|
54
54
|
AppMonitor class with a default send_alert method, and have your
|
55
55
|
individual monitor classes inherit from that.
|
56
56
|
|
data/lib/simple_monitor.rb
CHANGED
@@ -4,9 +4,14 @@ module SimpleMonitor
|
|
4
4
|
attr_reader :options
|
5
5
|
attr_accessor :logger
|
6
6
|
|
7
|
+
# Sets if logging should only occur when
|
8
|
+
# you call it, skips implementation logging
|
9
|
+
attr_accessor :only_explicit_logging
|
10
|
+
|
7
11
|
LOG_METHODS = %w[info warn error debug].freeze
|
8
12
|
|
9
13
|
def initialize(options = {})
|
14
|
+
self.only_explicit_logging = options.delete(:only_explicit_logging)
|
10
15
|
@options = options
|
11
16
|
end
|
12
17
|
|
@@ -25,7 +30,9 @@ module SimpleMonitor
|
|
25
30
|
end
|
26
31
|
|
27
32
|
def warn_alert
|
28
|
-
|
33
|
+
unless only_explicit_logging
|
34
|
+
warn(alert_log_message)
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
# Public: Message to log in case of an alert
|
@@ -38,7 +45,9 @@ module SimpleMonitor
|
|
38
45
|
end
|
39
46
|
|
40
47
|
def info_passed
|
41
|
-
|
48
|
+
unless only_explicit_logging
|
49
|
+
info(passed_log_message)
|
50
|
+
end
|
42
51
|
end
|
43
52
|
|
44
53
|
# Public: Message to log in case of a check passing
|
data/spec/simple_monitor_spec.rb
CHANGED
@@ -20,6 +20,11 @@ describe SimpleMonitor do
|
|
20
20
|
monitor = TestMonitor.new(:foo => :bar)
|
21
21
|
monitor.options[:foo].should == :bar
|
22
22
|
end
|
23
|
+
|
24
|
+
it "extacts :only_explicit_logging from the passed options" do
|
25
|
+
TestMonitor.new.only_explicit_logging.should be_nil
|
26
|
+
TestMonitor.new(:only_explicit_logging => true).only_explicit_logging.should be_true
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
describe SimpleMonitor, "logger" do
|
@@ -66,6 +71,12 @@ describe SimpleMonitor, "running the check" do
|
|
66
71
|
subject.check
|
67
72
|
end
|
68
73
|
|
74
|
+
it "can bypass the logging if only_explicit_logging is set" do
|
75
|
+
subject.only_explicit_logging = true
|
76
|
+
logger.should_not_receive(:warn)
|
77
|
+
subject.check
|
78
|
+
end
|
79
|
+
|
69
80
|
it "sends an alert" do
|
70
81
|
subject.check
|
71
82
|
subject.last_alert.should == "Test Monitor Alert"
|
@@ -84,6 +95,12 @@ describe SimpleMonitor, "running the check" do
|
|
84
95
|
subject.check
|
85
96
|
end
|
86
97
|
|
98
|
+
it "can bypass the logging if only_explicit_logging is set" do
|
99
|
+
subject.only_explicit_logging = true
|
100
|
+
logger.should_not_receive(:info)
|
101
|
+
subject.check
|
102
|
+
end
|
103
|
+
|
87
104
|
it "doesn't send an alert" do
|
88
105
|
subject.check
|
89
106
|
subject.last_alert.should be_nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_monitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
17
|
-
requirement: &
|
17
|
+
requirement: &2155990900 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2155990900
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &2155968720 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2155968720
|
37
37
|
description: ''
|
38
38
|
email:
|
39
39
|
- xternal1+github@gmail.com
|