sensu-logger 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/sensu-logger.gemspec +2 -2
- metadata +4 -14
- data/.gitignore +0 -22
- data/.travis.yml +0 -15
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/spec/helpers.rb +0 -29
- data/spec/logger_spec.rb +0 -46
- data/spec/stream_spec.rb +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d5549c1986b17f0b1dd69f1dd4964a620a7c59b
|
4
|
+
data.tar.gz: e10d952f95550cdb42c02304b2b441e18c106217
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a370f61edab7f22864b5df5282ffd8604aed22c167971840e0c496266c02d6df8895851a998558f710135589884dceb64cdcba7041f1155d5a99759920ae2a53
|
7
|
+
data.tar.gz: 8f5c0b44d130ced97c3fe18990beb0aba9a4d8c40b3478b57e0e0e34ca021f2e656635da40217bc9f479cec6c0961f53841faa16cdeb947e1e3d4c39364ca032
|
data/LICENSE.txt
CHANGED
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 = "1.2.
|
5
|
+
spec.version = "1.2.1"
|
6
6
|
spec.authors = ["Sean Porter"]
|
7
7
|
spec.email = ["portertech@gmail.com"]
|
8
8
|
spec.summary = "The Sensu logger library"
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.homepage = "https://github.com/sensu/sensu-logger"
|
11
11
|
spec.license = "MIT"
|
12
12
|
|
13
|
-
spec.files =
|
13
|
+
spec.files = Dir.glob("lib/**/*") + %w[sensu-logger.gemspec README.md LICENSE.txt]
|
14
14
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ["lib"]
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-json
|
@@ -101,19 +101,12 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- ".gitignore"
|
105
|
-
- ".travis.yml"
|
106
|
-
- Gemfile
|
107
104
|
- LICENSE.txt
|
108
105
|
- README.md
|
109
|
-
- Rakefile
|
110
106
|
- lib/sensu/logger.rb
|
111
107
|
- lib/sensu/logger/constants.rb
|
112
108
|
- lib/sensu/logger/stream.rb
|
113
109
|
- sensu-logger.gemspec
|
114
|
-
- spec/helpers.rb
|
115
|
-
- spec/logger_spec.rb
|
116
|
-
- spec/stream_spec.rb
|
117
110
|
homepage: https://github.com/sensu/sensu-logger
|
118
111
|
licenses:
|
119
112
|
- MIT
|
@@ -134,11 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
127
|
version: '0'
|
135
128
|
requirements: []
|
136
129
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.3
|
138
131
|
signing_key:
|
139
132
|
specification_version: 4
|
140
133
|
summary: The Sensu logger library
|
141
|
-
test_files:
|
142
|
-
- spec/helpers.rb
|
143
|
-
- spec/logger_spec.rb
|
144
|
-
- spec/stream_spec.rb
|
134
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.travis.yml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.0.0
|
5
|
-
- 2.1.0
|
6
|
-
- 2.2.0
|
7
|
-
- 2.2.3
|
8
|
-
- 2.3.0
|
9
|
-
- jruby-1.7.23
|
10
|
-
notifications:
|
11
|
-
irc:
|
12
|
-
- "irc.freenode.net#sensu"
|
13
|
-
addons:
|
14
|
-
code_climate:
|
15
|
-
repo_token: fb78330fb5aad0202b51f0fe25829ecb08229dc8236fb5fd573cd95997603527
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/spec/helpers.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require "eventmachine"
|
3
|
-
|
4
|
-
unless RUBY_VERSION < "1.9" || RUBY_PLATFORM =~ /java/
|
5
|
-
require "codeclimate-test-reporter"
|
6
|
-
CodeClimate::TestReporter.start
|
7
|
-
end
|
8
|
-
|
9
|
-
module Helpers
|
10
|
-
def timer(delay, &callback)
|
11
|
-
periodic_timer = EM::PeriodicTimer.new(delay) do
|
12
|
-
callback.call
|
13
|
-
periodic_timer.cancel
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def async_wrapper(&callback)
|
18
|
-
EM.run do
|
19
|
-
timer(10) do
|
20
|
-
raise "test timed out"
|
21
|
-
end
|
22
|
-
callback.call
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def async_done
|
27
|
-
EM.stop_event_loop
|
28
|
-
end
|
29
|
-
end
|
data/spec/logger_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
-
require "sensu/logger"
|
3
|
-
|
4
|
-
describe "Sensu::Logger" do
|
5
|
-
include Helpers
|
6
|
-
|
7
|
-
it "can provide the logger API" do
|
8
|
-
expect(Sensu::Logger).to respond_to(:setup, :get)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can set up a log stream" do
|
12
|
-
logger = Sensu::Logger.setup
|
13
|
-
expect(logger.info("some info", {:foo => "bar"})).to be(true)
|
14
|
-
logger.level = :warn
|
15
|
-
expect(logger.info("some info", {:foo => "bar"})).to be(false)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "can retrive the current log stream" do
|
19
|
-
logger = Sensu::Logger.setup
|
20
|
-
expect(Sensu::Logger.get).to eq(logger)
|
21
|
-
expect(Sensu::Logger.get).to eq(logger)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "can setup a log stream if one doesn't exist" do
|
25
|
-
logger = Sensu::Logger.get
|
26
|
-
expect(logger.info("some info", {:foo => "bar"})).to be(true)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "can setup a log stream with a log level and file" do
|
30
|
-
stdout = STDOUT.dup
|
31
|
-
file = Tempfile.new("sensu-logger")
|
32
|
-
logger = Sensu::Logger.setup(:log_level => :warn, :log_file => file.path)
|
33
|
-
expect(logger.info("some info", {:foo => "bar"})).to be(false)
|
34
|
-
expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
|
35
|
-
file_contents = IO.read(file.path)
|
36
|
-
expect(file_contents).to match(/a warning/)
|
37
|
-
logger.reopen(stdout)
|
38
|
-
expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "can setup a log stream with options if one doesn't exist" do
|
42
|
-
logger = Sensu::Logger.get(:log_level => :warn)
|
43
|
-
expect(logger.info("some info", {:foo => "bar"})).to be(false)
|
44
|
-
expect(logger.warn("a warning", {:foo => "bar"})).to be(true)
|
45
|
-
end
|
46
|
-
end
|
data/spec/stream_spec.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "helpers")
|
2
|
-
require "sensu/logger/stream"
|
3
|
-
require "tempfile"
|
4
|
-
|
5
|
-
describe "Sensu::Logger::Stream" do
|
6
|
-
include Helpers
|
7
|
-
|
8
|
-
before do
|
9
|
-
@stream = Sensu::Logger::Stream.new
|
10
|
-
end
|
11
|
-
|
12
|
-
it "can log events with different levels" do
|
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
|
-
@stream.level = :debug
|
19
|
-
expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
|
20
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
21
|
-
@stream.level = :warn
|
22
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(false)
|
23
|
-
expect(@stream.warn("a warning", {:foo => "bar"})).to be(true)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "can reopen STDERR/STDOUT and redirect them to a log file" do
|
27
|
-
stdout = STDOUT.dup
|
28
|
-
file = Tempfile.new("sensu-logger")
|
29
|
-
@stream.reopen(file.path)
|
30
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
31
|
-
@stream.reopen(stdout)
|
32
|
-
file_contents = IO.read(file.path)
|
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
|
-
@stream.reopen("/untouchable.log")
|
37
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "can setup signal traps to toggle debug logging and reopen the log file" do
|
41
|
-
@stream.setup_signal_traps
|
42
|
-
expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
|
43
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
44
|
-
Process.kill("TRAP", Process.pid)
|
45
|
-
sleep 0.5
|
46
|
-
expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
|
47
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
48
|
-
Process.kill("TRAP", Process.pid)
|
49
|
-
sleep 0.5
|
50
|
-
expect(@stream.debug("some debug info", {:foo => "bar"})).to be(false)
|
51
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
52
|
-
@stream.level = :warn
|
53
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(false)
|
54
|
-
Process.kill("TRAP", Process.pid)
|
55
|
-
sleep 0.5
|
56
|
-
expect(@stream.debug("some debug info", {:foo => "bar"})).to be(true)
|
57
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
58
|
-
Process.kill("TRAP", Process.pid)
|
59
|
-
sleep 0.5
|
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
|
-
@stream.reopen(STDOUT)
|
64
|
-
Process.kill("USR2", Process.pid)
|
65
|
-
sleep 0.5
|
66
|
-
expect(@stream.error("an error", {:foo => "bar"})).to be(true)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "can operate as expected within the eventmachine reactor" do
|
70
|
-
async_wrapper do
|
71
|
-
stdout = STDOUT.dup
|
72
|
-
file = Tempfile.new("sensu-logger")
|
73
|
-
@stream.reopen(file.path)
|
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
|
-
timer(1) do
|
79
|
-
@stream.reopen(stdout)
|
80
|
-
expected = [
|
81
|
-
{:level => "info", :message => "some info", :foo => "bar"},
|
82
|
-
{:level => "warn", :message => "a warning", :foo => "bar"},
|
83
|
-
{:level => "error", :message => "an error", :foo => "bar"}
|
84
|
-
]
|
85
|
-
file_contents = IO.read(file.path)
|
86
|
-
parsed_contents = file_contents.lines.map do |line|
|
87
|
-
parsed_line = Sensu::JSON.load(line)
|
88
|
-
parsed_line.delete(:timestamp)
|
89
|
-
parsed_line
|
90
|
-
end
|
91
|
-
expect(parsed_contents).to eq(expected)
|
92
|
-
async_done
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
it "can write remaining log events to a log file when the eventmachine reactor stops" do
|
98
|
-
stdout = STDOUT.dup
|
99
|
-
file = Tempfile.new("sensu-logger")
|
100
|
-
async_wrapper do
|
101
|
-
@stream.reopen(file.path)
|
102
|
-
1000.times do
|
103
|
-
expect(@stream.info("some info", {:foo => "bar"})).to be(true)
|
104
|
-
end
|
105
|
-
EM.stop
|
106
|
-
end
|
107
|
-
@stream.reopen(stdout)
|
108
|
-
expect(IO.read(file.path).split("\n").size).to eq(1000)
|
109
|
-
end
|
110
|
-
end
|