sensu-logger 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4db534173e30cf3979d6da7ff7f265295ec81355
4
- data.tar.gz: 67965cb16d8007580121d805571a05dbfdff7ebf
3
+ metadata.gz: d438ad15896f27c173da421d082fd92fc248eaa7
4
+ data.tar.gz: 5782ee85752b9458722bbc5f57065b81622426e7
5
5
  SHA512:
6
- metadata.gz: bea338ccf9f40ca351c1b1a30c8bbe880c041f0544bd45eb670c12db9af20c4c2c60f548ad4707b0f3e64df55a1afdef67ca66c2ebb8b8807e789bcf0d49c183
7
- data.tar.gz: 97207727a424296216289e5a9476a6c4ab012285f9df9a04c2694b4d7b4673172461d2877bb203eeb8c7b788bc50e9b5269f2c00f1a15f2923e6a145a425d1f2
6
+ metadata.gz: d61ec07629c6b621b0aa72fa7345bd7aec6d63f5227583c2d166cf454ba79956997088aba13201dd27d2b52dd24b2b85e3f7239dfe244954a944a94593999f7a
7
+ data.tar.gz: a46e3338e9e3f359c98769ef1746e3c888f52d7afabdda60853833e492fbe79cdce69d3cd99421d1c360c33020474b9fe18cca84738a3f3e4f45e216d46d0935
data/sensu-logger.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-logger"
5
- spec.version = "0.0.1"
5
+ spec.version = "1.0.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu logger library"
data/spec/logger_spec.rb CHANGED
@@ -5,42 +5,42 @@ describe "Sensu::Logger" do
5
5
  include Helpers
6
6
 
7
7
  it "can provide the logger API" do
8
- Sensu::Logger.should respond_to(:setup, :get)
8
+ expect(Sensu::Logger).to respond_to(:setup, :get)
9
9
  end
10
10
 
11
11
  it "can set up a log stream" do
12
12
  logger = Sensu::Logger.setup
13
- logger.info("some info", {:foo => "bar"}).should be_true
13
+ expect(logger.info("some info", {:foo => "bar"})).to be(true)
14
14
  logger.level = :warn
15
- logger.info("some info", {:foo => "bar"}).should be_false
15
+ expect(logger.info("some info", {:foo => "bar"})).to be(false)
16
16
  end
17
17
 
18
18
  it "can retrive the current log stream" do
19
19
  logger = Sensu::Logger.setup
20
- Sensu::Logger.get.should eq(logger)
21
- Sensu::Logger.get.should eq(logger)
20
+ expect(Sensu::Logger.get).to eq(logger)
21
+ expect(Sensu::Logger.get).to eq(logger)
22
22
  end
23
23
 
24
24
  it "can setup a log stream if one doesn't exist" do
25
25
  logger = Sensu::Logger.get
26
- logger.info("some info", {:foo => "bar"}).should be_true
26
+ expect(logger.info("some info", {:foo => "bar"})).to be(true)
27
27
  end
28
28
 
29
29
  it "can setup a log stream with a log level and file" do
30
30
  stdout = STDOUT.dup
31
31
  file = Tempfile.new("sensu-logger")
32
32
  logger = Sensu::Logger.setup(:log_level => :warn, :log_file => file.path)
33
- logger.info("some info", {:foo => "bar"}).should be_false
34
- logger.warn("a warning", {:foo => "bar"}).should be_true
33
+ expect(logger.info("some info", {:foo => "bar"})).to be(false)
34
+ expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
35
35
  file_contents = IO.read(file.path)
36
- file_contents.should match(/a warning/)
36
+ expect(file_contents).to match(/a warning/)
37
37
  logger.reopen(stdout)
38
- logger.warn("a warning", {:foo => "bar"}).should be_true
38
+ expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
39
39
  end
40
40
 
41
41
  it "can setup a log stream with options if one doesn't exist" do
42
42
  logger = Sensu::Logger.get(:log_level => :warn)
43
- logger.info("some info", {:foo => "bar"}).should be_false
44
- logger.warn("a warning", {:foo => "bar"}).should be_true
43
+ expect(logger.info("some info", {:foo => "bar"})).to be(false)
44
+ expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
45
45
  end
46
46
  end
data/spec/stream_spec.rb CHANGED
@@ -10,60 +10,60 @@ describe "Sensu::Logger::Stream" do
10
10
  end
11
11
 
12
12
  it "can log events with different levels" do
13
- @stream.debug("some debug info", {:foo => "bar"}).should be_false
14
- @stream.info("some info", {:foo => "bar"}).should be_true
15
- @stream.warn("a warning", {:foo => "bar"}).should be_true
16
- @stream.error("an error", {:foo => "bar"}).should be_true
17
- @stream.fatal("something exploded", {:foo => "bar"}).should be_true
13
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
14
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
15
+ expect(@stream.warn("a warning", {:foo => "bar"})).to be(true)
16
+ expect(@stream.error("an error", {:foo => "bar"})).to be(true)
17
+ expect(@stream.fatal("something exploded", {:foo => "bar"})).to be(true)
18
18
  @stream.level = :debug
19
- @stream.debug("some debug info", {:foo => "bar"}).should be_true
20
- @stream.info("some info", {:foo => "bar"}).should be_true
19
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
20
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
21
21
  @stream.level = :warn
22
- @stream.info("some info", {:foo => "bar"}).should be_false
23
- @stream.warn("a warning", {:foo => "bar"}).should be_true
22
+ expect(@stream.info("some info", {:foo => "bar"})).to be(false)
23
+ expect(@stream.warn("a warning", {:foo => "bar"})).to be(true)
24
24
  end
25
25
 
26
26
  it "can reopen STDERR/STDOUT and redirect them to a log file" do
27
27
  stdout = STDOUT.dup
28
28
  file = Tempfile.new("sensu-logger")
29
29
  @stream.reopen(file.path)
30
- @stream.info("some info", {:foo => "bar"}).should be_true
30
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
31
31
  @stream.reopen(stdout)
32
32
  file_contents = IO.read(file.path)
33
- file_contents.should match(/timestamp/)
34
- file_contents.should match(/"message":"some info"/)
35
- file_contents.should match(/"foo":"bar"/)
33
+ expect(file_contents).to match(/timestamp/)
34
+ expect(file_contents).to match(/"message":"some info"/)
35
+ expect(file_contents).to match(/"foo":"bar"/)
36
36
  @stream.reopen("/untouchable.log")
37
- @stream.info("some info", {:foo => "bar"}).should be_true
37
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
38
38
  end
39
39
 
40
40
  it "can setup signal traps to toggle debug logging and reopen the log file" do
41
41
  @stream.setup_signal_traps
42
- @stream.debug("some debug info", {:foo => "bar"}).should be_false
43
- @stream.info("some info", {:foo => "bar"}).should be_true
42
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
43
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
44
44
  Process.kill("TRAP", Process.pid)
45
45
  sleep 0.5
46
- @stream.debug("some debug info", {:foo => "bar"}).should be_true
47
- @stream.info("some info", {:foo => "bar"}).should be_true
46
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
47
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
48
48
  Process.kill("TRAP", Process.pid)
49
49
  sleep 0.5
50
- @stream.debug("some debug info", {:foo => "bar"}).should be_false
51
- @stream.info("some info", {:foo => "bar"}).should be_true
50
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
51
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
52
52
  @stream.level = :warn
53
- @stream.info("some info", {:foo => "bar"}).should be_false
53
+ expect(@stream.info("some info", {:foo => "bar"})).to be(false)
54
54
  Process.kill("TRAP", Process.pid)
55
55
  sleep 0.5
56
- @stream.debug("some debug info", {:foo => "bar"}).should be_true
57
- @stream.info("some info", {:foo => "bar"}).should be_true
56
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
57
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
58
58
  Process.kill("TRAP", Process.pid)
59
59
  sleep 0.5
60
- @stream.debug("some debug info", {:foo => "bar"}).should be_false
61
- @stream.info("some info", {:foo => "bar"}).should be_false
62
- @stream.warn("a warning", {:foo => "bar"}).should be_true
60
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
61
+ expect(@stream.info("some info", {:foo => "bar"})).to be(false)
62
+ expect(@stream.warn("a warning", {:foo => "bar"})).to be(true)
63
63
  @stream.reopen(STDOUT)
64
64
  Process.kill("USR2", Process.pid)
65
65
  sleep 0.5
66
- @stream.error("an error", {:foo => "bar"}).should be_true
66
+ expect(@stream.error("an error", {:foo => "bar"})).to be(true)
67
67
  end
68
68
 
69
69
  it "can operate as expected within the eventmachine reactor" do
@@ -71,10 +71,10 @@ describe "Sensu::Logger::Stream" do
71
71
  stdout = STDOUT.dup
72
72
  file = Tempfile.new("sensu-logger")
73
73
  @stream.reopen(file.path)
74
- @stream.debug("some debug info", {:foo => "bar"}).should be_false
75
- @stream.info("some info", {:foo => "bar"}).should be_true
76
- @stream.warn("a warning", {:foo => "bar"}).should be_true
77
- @stream.error("an error", {:foo => "bar"}).should be_true
74
+ expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
75
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
76
+ expect(@stream.warn("a warning", {:foo => "bar"})).to be(true)
77
+ expect(@stream.error("an error", {:foo => "bar"})).to be(true)
78
78
  timer(1) do
79
79
  @stream.reopen(stdout)
80
80
  expected = [
@@ -88,7 +88,7 @@ describe "Sensu::Logger::Stream" do
88
88
  parsed_line.delete(:timestamp)
89
89
  parsed_line
90
90
  end
91
- parsed_contents.should eq(expected)
91
+ expect(parsed_contents).to eq(expected)
92
92
  async_done
93
93
  end
94
94
  end
@@ -100,11 +100,11 @@ describe "Sensu::Logger::Stream" do
100
100
  async_wrapper do
101
101
  @stream.reopen(file.path)
102
102
  1000.times do
103
- @stream.info("some info", {:foo => "bar"}).should be_true
103
+ expect(@stream.info("some info", {:foo => "bar"})).to be(true)
104
104
  end
105
105
  EM.stop
106
106
  end
107
107
  @stream.reopen(stdout)
108
- IO.read(file.path).split("\n").size.should eq(1000)
108
+ expect(IO.read(file.path).split("\n").size).to eq(1000)
109
109
  end
110
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-em