steno 1.2.2 → 1.2.4
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.
- checksums.yaml +9 -9
- data/lib/steno/sink/eventlog.rb +7 -7
- data/lib/steno/sink/syslog.rb +3 -2
- data/lib/steno/version.rb +1 -1
- data/spec/unit/sink/eventlog_spec.rb +1 -1
- data/spec/unit/sink/syslog_spec.rb +3 -2
- data/steno.gemspec +1 -2
- metadata +9 -26
- data/lib/steno/http_handler.rb +0 -41
- data/spec/unit/http_handler_spec.rb +0 -73
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmJiYWIyYzUzZjdlZjk2YzIwY2Q3ZDk5YTY4NTgxYzE4OWQ4MGJiZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
MzUzMjIwZTNjYTAzYWIyZDE2MmNmNTNiOTBkMzIzZmRiMDJmMGFkOQ==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGM2OWU1ZGZlYmEyZTVlODMyYzJiZDU5ZDliMWI0ZjExNWMwYzFmODU5NmNl
|
10
|
+
ZDRlYjY5NzEzMjA5NmI0NTQwMmE0MjBiNDBkNTc2NDQ2ZGIxZTVkNDhhNzA2
|
11
|
+
MDFiNWMxMjhhOTA2YzUyYzMxN2ZhMzk1YjZlYmIzYjdkZDk2ZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Zjc3ZmVkY2QzNWZjZDUxYWNiYWQ5MWRhYjlkNjM2ZTg1Nzc0MDBhNWNlZWY4
|
14
|
+
ZDUzYjg1YWJiZDUxYzlkN2E0ZDg1NTk5YzMwMzdiMzRkMGZhNDdhOTMyMWUw
|
15
|
+
ZDE0YTVmNTBkZWI1MmNjNGEyNjgyOWI1YWQyYTRkNjgzNTFhZWY=
|
data/lib/steno/sink/eventlog.rb
CHANGED
@@ -9,13 +9,13 @@ if Steno::Sink::WINDOWS
|
|
9
9
|
include Singleton
|
10
10
|
|
11
11
|
LOG_LEVEL_MAP = {
|
12
|
-
:fatal => Win32::EventLog::
|
13
|
-
:error => Win32::EventLog::
|
14
|
-
:warn => Win32::EventLog::
|
15
|
-
:info => Win32::EventLog::
|
16
|
-
:debug => Win32::EventLog::
|
17
|
-
:debug1 => Win32::EventLog::
|
18
|
-
:debug2 => Win32::EventLog::
|
12
|
+
:fatal => Win32::EventLog::ERROR_TYPE,
|
13
|
+
:error => Win32::EventLog::ERROR_TYPE,
|
14
|
+
:warn => Win32::EventLog::WARN_TYPE,
|
15
|
+
:info => Win32::EventLog::INFO_TYPE,
|
16
|
+
:debug => Win32::EventLog::INFO_TYPE,
|
17
|
+
:debug1 => Win32::EventLog::INFO_TYPE,
|
18
|
+
:debug2 => Win32::EventLog::INFO_TYPE,
|
19
19
|
}
|
20
20
|
|
21
21
|
def initialize
|
data/lib/steno/sink/syslog.rb
CHANGED
@@ -9,6 +9,7 @@ unless Steno::Sink::WINDOWS
|
|
9
9
|
include Singleton
|
10
10
|
|
11
11
|
MAX_MESSAGE_SIZE = 1024 * 3
|
12
|
+
TRUNCATE_POSTFIX = "..."
|
12
13
|
|
13
14
|
LOG_LEVEL_MAP = {
|
14
15
|
:fatal => Syslog::LOG_CRIT,
|
@@ -48,8 +49,8 @@ unless Steno::Sink::WINDOWS
|
|
48
49
|
def truncate_record(record)
|
49
50
|
return record if record.message.size <= MAX_MESSAGE_SIZE
|
50
51
|
|
51
|
-
truncated = record.message.slice(0
|
52
|
-
truncated <<
|
52
|
+
truncated = record.message.slice(0...(MAX_MESSAGE_SIZE - TRUNCATE_POSTFIX.size))
|
53
|
+
truncated << TRUNCATE_POSTFIX
|
53
54
|
Steno::Record.new(record.source, record.log_level,
|
54
55
|
truncated,
|
55
56
|
[record.file, record.lineno, record.method],
|
data/lib/steno/version.rb
CHANGED
@@ -25,7 +25,7 @@ if Steno::Sink::WINDOWS
|
|
25
25
|
sink.codec = codec
|
26
26
|
|
27
27
|
eventlog.should_receive(:report_event).with(:source => "CloudFoundry",
|
28
|
-
:event_type => Win32::EventLog::
|
28
|
+
:event_type => Win32::EventLog::INFO_TYPE,
|
29
29
|
:data => record.message)
|
30
30
|
|
31
31
|
sink.add_record(record)
|
@@ -47,12 +47,13 @@ unless Steno::Sink::WINDOWS
|
|
47
47
|
sink.open(identity)
|
48
48
|
|
49
49
|
truncated = record_with_big_message.message.
|
50
|
-
slice(0..(Steno::Sink::Syslog::MAX_MESSAGE_SIZE) -
|
51
|
-
truncated <<
|
50
|
+
slice(0..(Steno::Sink::Syslog::MAX_MESSAGE_SIZE) - 4)
|
51
|
+
truncated << Steno::Sink::Syslog::TRUNCATE_POSTFIX
|
52
52
|
codec = double("codec")
|
53
53
|
codec.should_receive(:encode_record) do |*args|
|
54
54
|
args.size.should == 1
|
55
55
|
args[0].message.should == truncated
|
56
|
+
args[0].message.size.should <= Steno::Sink::Syslog::MAX_MESSAGE_SIZE
|
56
57
|
|
57
58
|
next args[0].message
|
58
59
|
end
|
data/steno.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.require_paths = ["lib"]
|
26
26
|
gem.version = Steno::VERSION
|
27
27
|
|
28
|
-
gem.add_dependency("grape")
|
29
28
|
gem.add_dependency("yajl-ruby", "~> 1.0")
|
30
29
|
gem.add_dependency("fluent-logger")
|
31
30
|
|
@@ -36,6 +35,6 @@ Gem::Specification.new do |gem|
|
|
36
35
|
|
37
36
|
if RUBY_PLATFORM=~ /mswin|mingw|cygwin/
|
38
37
|
gem.platform = Gem::Platform::CURRENT
|
39
|
-
gem.add_dependency("win32-eventlog")
|
38
|
+
gem.add_dependency("win32-eventlog", "~> 0.6.0")
|
40
39
|
end
|
41
40
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mpage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: grape
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ! '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: yajl-ruby
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,32 +102,31 @@ executables:
|
|
116
102
|
extensions: []
|
117
103
|
extra_rdoc_files: []
|
118
104
|
files:
|
105
|
+
- LICENSE
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
119
108
|
- bin/steno-prettify
|
109
|
+
- lib/steno.rb
|
110
|
+
- lib/steno/codec.rb
|
120
111
|
- lib/steno/codec/base.rb
|
121
112
|
- lib/steno/codec/json.rb
|
122
|
-
- lib/steno/codec.rb
|
123
113
|
- lib/steno/config.rb
|
124
114
|
- lib/steno/context.rb
|
125
115
|
- lib/steno/core_ext.rb
|
126
116
|
- lib/steno/errors.rb
|
127
|
-
- lib/steno/http_handler.rb
|
128
117
|
- lib/steno/json_prettifier.rb
|
129
118
|
- lib/steno/log_level.rb
|
130
119
|
- lib/steno/logger.rb
|
131
120
|
- lib/steno/record.rb
|
121
|
+
- lib/steno/sink.rb
|
132
122
|
- lib/steno/sink/base.rb
|
133
123
|
- lib/steno/sink/counter.rb
|
134
124
|
- lib/steno/sink/eventlog.rb
|
135
125
|
- lib/steno/sink/fluentd.rb
|
136
126
|
- lib/steno/sink/io.rb
|
137
127
|
- lib/steno/sink/syslog.rb
|
138
|
-
- lib/steno/sink.rb
|
139
128
|
- lib/steno/tagged_logger.rb
|
140
129
|
- lib/steno/version.rb
|
141
|
-
- lib/steno.rb
|
142
|
-
- LICENSE
|
143
|
-
- Rakefile
|
144
|
-
- README.md
|
145
130
|
- spec/spec_helper.rb
|
146
131
|
- spec/support/barrier.rb
|
147
132
|
- spec/support/null_sink.rb
|
@@ -149,7 +134,6 @@ files:
|
|
149
134
|
- spec/unit/config_spec.rb
|
150
135
|
- spec/unit/context_spec.rb
|
151
136
|
- spec/unit/core_ext_spec.rb
|
152
|
-
- spec/unit/http_handler_spec.rb
|
153
137
|
- spec/unit/json_codec_spec.rb
|
154
138
|
- spec/unit/json_prettifier_spec.rb
|
155
139
|
- spec/unit/log_level_spec.rb
|
@@ -182,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
166
|
version: '0'
|
183
167
|
requirements: []
|
184
168
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.2.2
|
186
170
|
signing_key:
|
187
171
|
specification_version: 4
|
188
172
|
summary: A logging library.
|
@@ -194,7 +178,6 @@ test_files:
|
|
194
178
|
- spec/unit/config_spec.rb
|
195
179
|
- spec/unit/context_spec.rb
|
196
180
|
- spec/unit/core_ext_spec.rb
|
197
|
-
- spec/unit/http_handler_spec.rb
|
198
181
|
- spec/unit/json_codec_spec.rb
|
199
182
|
- spec/unit/json_prettifier_spec.rb
|
200
183
|
- spec/unit/log_level_spec.rb
|
data/lib/steno/http_handler.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require "steno"
|
2
|
-
|
3
|
-
require "grape"
|
4
|
-
|
5
|
-
module Steno
|
6
|
-
end
|
7
|
-
|
8
|
-
class Steno::HttpHandler < Grape::API
|
9
|
-
format :json
|
10
|
-
|
11
|
-
resource :loggers do
|
12
|
-
get :levels do
|
13
|
-
Steno.logger_level_snapshot
|
14
|
-
end
|
15
|
-
|
16
|
-
put :levels do
|
17
|
-
missing = [:regexp, :level].select { |p| !params.key?(p) }.map(&:to_s)
|
18
|
-
|
19
|
-
if !missing.empty?
|
20
|
-
error!("Missing query parameters: #{missing}", 400)
|
21
|
-
end
|
22
|
-
|
23
|
-
regexp = nil
|
24
|
-
begin
|
25
|
-
regexp = Regexp.new(params[:regexp])
|
26
|
-
rescue => e
|
27
|
-
error!("Invalid regexp", 400)
|
28
|
-
end
|
29
|
-
|
30
|
-
level = params[:level].to_sym
|
31
|
-
if !Steno::Logger::LEVELS.key?(level)
|
32
|
-
levels = Steno::Logger::LEVELS.keys.map(&:to_s)
|
33
|
-
error!("Unknown level: #{level}. Supported levels are: #{levels}", 400)
|
34
|
-
end
|
35
|
-
|
36
|
-
Steno.set_logger_regexp(regexp, level)
|
37
|
-
|
38
|
-
"ok"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
require "steno/http_handler"
|
4
|
-
|
5
|
-
describe Steno::HttpHandler do
|
6
|
-
include Rack::Test::Methods
|
7
|
-
|
8
|
-
let(:config) { Steno::Config.new }
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
Steno.init(config)
|
12
|
-
end
|
13
|
-
|
14
|
-
def app
|
15
|
-
Steno::HttpHandler
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "GET /loggers/levels" do
|
19
|
-
it "returns a hash of logger name to level" do
|
20
|
-
get "/loggers/levels"
|
21
|
-
json_body.should == {}
|
22
|
-
|
23
|
-
foo = Steno.logger("foo")
|
24
|
-
foo.level = :debug
|
25
|
-
|
26
|
-
bar = Steno.logger("bar")
|
27
|
-
bar.level = :info
|
28
|
-
|
29
|
-
get "/loggers/levels"
|
30
|
-
json_body.should == { "foo" => "debug", "bar" => "info" }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "PUT /loggers/levels" do
|
35
|
-
it "returns an error on missing parameters" do
|
36
|
-
put "/loggers/levels"
|
37
|
-
last_response.status.should == 400
|
38
|
-
json_body["error"].should match(/Missing query parameters/)
|
39
|
-
|
40
|
-
put "/loggers/levels", :regexp => "hi"
|
41
|
-
last_response.status.should == 400
|
42
|
-
json_body["error"].should match(/Missing query parameters/)
|
43
|
-
|
44
|
-
put "/loggers/levels", :level => "debug"
|
45
|
-
last_response.status.should == 400
|
46
|
-
json_body["error"].should match(/Missing query parameters/)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns an error on invalid log levels" do
|
50
|
-
put "/loggers/levels", :regexp => "hi", :level => "foobar"
|
51
|
-
last_response.status.should == 400
|
52
|
-
json_body["error"].should match(/Unknown level/)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "updates log levels for loggers whose name matches the regexp" do
|
56
|
-
foo = Steno.logger("foo")
|
57
|
-
foo.level = :debug
|
58
|
-
|
59
|
-
bar = Steno.logger("bar")
|
60
|
-
bar.level = :warn
|
61
|
-
|
62
|
-
put "/loggers/levels", :regexp => "f", :level => "error"
|
63
|
-
last_response.status.should == 200
|
64
|
-
|
65
|
-
foo.level.should == :error
|
66
|
-
bar.level.should == :warn
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def json_body
|
71
|
-
Yajl::Parser.parse(last_response.body)
|
72
|
-
end
|
73
|
-
end
|