steno 1.2.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE +7136 -0
  3. data/README.md +78 -0
  4. data/Rakefile +16 -0
  5. data/bin/steno-prettify +99 -0
  6. data/lib/steno.rb +133 -0
  7. data/lib/steno/codec.rb +2 -0
  8. data/lib/steno/codec/base.rb +34 -0
  9. data/lib/steno/codec/json.rb +36 -0
  10. data/lib/steno/config.rb +97 -0
  11. data/lib/steno/context.rb +59 -0
  12. data/lib/steno/core_ext.rb +11 -0
  13. data/lib/steno/errors.rb +3 -0
  14. data/lib/steno/http_handler.rb +41 -0
  15. data/lib/steno/json_prettifier.rb +131 -0
  16. data/lib/steno/log_level.rb +24 -0
  17. data/lib/steno/logger.rb +174 -0
  18. data/lib/steno/record.rb +41 -0
  19. data/lib/steno/sink.rb +6 -0
  20. data/lib/steno/sink/base.rb +38 -0
  21. data/lib/steno/sink/counter.rb +44 -0
  22. data/lib/steno/sink/eventlog.rb +46 -0
  23. data/lib/steno/sink/fluentd.rb +31 -0
  24. data/lib/steno/sink/io.rb +72 -0
  25. data/lib/steno/sink/syslog.rb +59 -0
  26. data/lib/steno/tagged_logger.rb +59 -0
  27. data/lib/steno/version.rb +3 -0
  28. data/spec/spec_helper.rb +6 -0
  29. data/spec/support/barrier.rb +22 -0
  30. data/spec/support/null_sink.rb +17 -0
  31. data/spec/support/shared_context_specs.rb +7 -0
  32. data/spec/unit/config_spec.rb +221 -0
  33. data/spec/unit/context_spec.rb +62 -0
  34. data/spec/unit/core_ext_spec.rb +38 -0
  35. data/spec/unit/http_handler_spec.rb +73 -0
  36. data/spec/unit/json_codec_spec.rb +48 -0
  37. data/spec/unit/json_prettifier_spec.rb +84 -0
  38. data/spec/unit/log_level_spec.rb +19 -0
  39. data/spec/unit/logger_spec.rb +101 -0
  40. data/spec/unit/record_spec.rb +30 -0
  41. data/spec/unit/sink/counter_spec.rb +27 -0
  42. data/spec/unit/sink/eventlog_spec.rb +41 -0
  43. data/spec/unit/sink/fluentd_spec.rb +46 -0
  44. data/spec/unit/sink/io_spec.rb +111 -0
  45. data/spec/unit/sink/syslog_spec.rb +74 -0
  46. data/spec/unit/steno_spec.rb +86 -0
  47. data/spec/unit/tagged_logger_spec.rb +33 -0
  48. data/steno-1.2.1.gem +0 -0
  49. data/steno.gemspec +41 -0
  50. metadata +224 -0
@@ -0,0 +1,74 @@
1
+ require "spec_helper"
2
+ unless Steno::Sink::WINDOWS
3
+ describe Steno::Sink::Syslog do
4
+ let(:level) do
5
+ Steno::Logger.lookup_level(:info)
6
+ end
7
+
8
+ let(:record) do
9
+ Steno::Record.new("source", level.name, "message")
10
+ end
11
+
12
+ let(:record_with_big_message) do
13
+ Steno::Record.new("source", level.name,
14
+ "a" * (Steno::Sink::Syslog::MAX_MESSAGE_SIZE + 1))
15
+ end
16
+
17
+ describe "#add_record" do
18
+ it "should append an encoded record with the correct priority" do
19
+ identity = "test"
20
+
21
+ syslog = double("syslog")
22
+ Syslog.should_receive(:open) \
23
+ .with(identity, Syslog::LOG_PID, Syslog::LOG_USER) \
24
+ .and_return(syslog)
25
+
26
+ sink = Steno::Sink::Syslog.instance
27
+ sink.open(identity)
28
+
29
+ codec = double("codec")
30
+ codec.should_receive(:encode_record).with(record).and_return(record.message)
31
+ sink.codec = codec
32
+
33
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", record.message)
34
+
35
+ sink.add_record(record)
36
+ end
37
+
38
+ it "should truncate the record message if its greater than than allowed size" do
39
+ identity = "test"
40
+
41
+ syslog = double("syslog")
42
+ Syslog.should_receive(:open) \
43
+ .with(identity, Syslog::LOG_PID, Syslog::LOG_USER) \
44
+ .and_return(syslog)
45
+
46
+ sink = Steno::Sink::Syslog.instance
47
+ sink.open(identity)
48
+
49
+ truncated = record_with_big_message.message.
50
+ slice(0..(Steno::Sink::Syslog::MAX_MESSAGE_SIZE) - 1)
51
+ truncated << "..."
52
+ codec = double("codec")
53
+ codec.should_receive(:encode_record) do |*args|
54
+ args.size.should == 1
55
+ args[0].message.should == truncated
56
+
57
+ next args[0].message
58
+ end
59
+
60
+ sink.codec = codec
61
+
62
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", truncated)
63
+
64
+ sink.add_record(record_with_big_message)
65
+ end
66
+ end
67
+
68
+ describe "#flush" do
69
+ it "should do nothing" do
70
+ Steno::Sink::Syslog.instance.flush
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,86 @@
1
+ require "spec_helper"
2
+
3
+ describe Steno do
4
+ let(:config) { Steno::Config.new }
5
+
6
+ before :each do
7
+ Steno.init(config)
8
+ end
9
+
10
+ describe "#logger" do
11
+ it "should return a new Steno::Logger instance" do
12
+ logger = Steno.logger("test")
13
+ logger.should_not be_nil
14
+ logger.name.should == "test"
15
+ end
16
+
17
+ it "should memoize loggers by name" do
18
+ logger1 = Steno.logger("test")
19
+ logger2 = Steno.logger("test")
20
+
21
+ logger1.object_id.should == logger2.object_id
22
+ end
23
+ end
24
+
25
+ describe "#set_logger_regexp" do
26
+ it "should modify the levels of existing loggers that match the regex" do
27
+ logger = Steno.logger("test")
28
+
29
+ logger.level.should == :info
30
+
31
+ Steno.set_logger_regexp(/te/, :debug)
32
+
33
+ logger.level.should == :debug
34
+ end
35
+
36
+ it "should modify the levels of new loggers after a regexp has been set" do
37
+ Steno.set_logger_regexp(/te/, :debug)
38
+
39
+ Steno.logger("te").level.should == :debug
40
+ end
41
+
42
+ it "should reset the levels of previously matching loggers when changed" do
43
+ Steno.set_logger_regexp(/foo/, :debug)
44
+
45
+ logger = Steno.logger("foo")
46
+ logger.level.should == :debug
47
+
48
+ Steno.set_logger_regexp(/bar/, :debug)
49
+
50
+ logger.level.should == :info
51
+ end
52
+ end
53
+
54
+ describe "#clear_logger_regexp" do
55
+ it "should reset any loggers matching the existing regexp" do
56
+ Steno.set_logger_regexp(/te/, :debug)
57
+
58
+ logger = Steno.logger("test")
59
+ logger.level.should == :debug
60
+
61
+ Steno.clear_logger_regexp
62
+
63
+ logger.level.should == :info
64
+ Steno.logger_regexp.should be_nil
65
+ end
66
+ end
67
+
68
+ describe "#logger_level_snapshot" do
69
+ it "should return a hash mapping logger name to level" do
70
+ loggers = []
71
+
72
+ expected = {
73
+ "foo" => :debug,
74
+ "bar" => :warn,
75
+ }
76
+
77
+ expected.each do |name, level|
78
+ # Prevent GC
79
+ loggers << Steno.logger(name)
80
+ loggers.last.level = level
81
+ end
82
+
83
+ Steno.logger_level_snapshot.should == expected
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,33 @@
1
+ describe Steno::TaggedLogger do
2
+ let(:sink) { NullSink.new }
3
+ let(:logger) { Steno::Logger.new("test", [sink]) }
4
+ let(:user_data) { { "foo" => "bar" } }
5
+ let(:tagged_logger) { Steno::TaggedLogger.new(logger, user_data) }
6
+
7
+ it "should add any user data to each log record" do
8
+ tagged_logger.info("testing", "test" => "data")
9
+ sink.records.size.should == 1
10
+ sink.records[0].data.should == user_data.merge("test" => "data")
11
+
12
+ tagged_logger.log_exception(RuntimeError.new("hi"))
13
+ sink.records.size.should == 2
14
+ sink.records[1].data.should == user_data.merge(:backtrace => nil)
15
+ end
16
+
17
+ it "should forward missing methods to the proxied logger" do
18
+ tagged_logger.level.should == :info
19
+ tagged_logger.level = :warn
20
+
21
+ logger.level.should == :warn
22
+
23
+ tagged_logger.level_active?(:info).should be_false
24
+ end
25
+
26
+ describe "#tag" do
27
+ it "should return a new tagged logger with merged user-data" do
28
+ tl = tagged_logger.tag("bar" => "baz")
29
+ tl.proxied_logger.should == logger
30
+ tl.user_data.should == user_data.merge("bar" => "baz")
31
+ end
32
+ end
33
+ end
data/steno-1.2.1.gem ADDED
Binary file
data/steno.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/steno/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["mpage"]
6
+ gem.email = ["mpage@rbcon.com"]
7
+ gem.description = "A thread-safe logging library designed to support" \
8
+ + " multiple log destinations."
9
+ gem.summary = "A logging library."
10
+ gem.homepage = "http://www.cloudfoundry.org"
11
+
12
+ gitignore = File.readlines(".gitignore").grep(/^[^#]/).map { |s| s.chomp }
13
+
14
+ # Ignore Gemfile, this is a library
15
+ gitignore << "Gemfile*"
16
+
17
+ glob = Dir["**/*"].
18
+ reject { |f| File.directory?(f) }.
19
+ reject { |f| gitignore.any? { |i| File.fnmatch(i, f) } }
20
+
21
+ gem.files = glob
22
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
+ gem.name = "steno"
25
+ gem.require_paths = ["lib"]
26
+ gem.version = Steno::VERSION
27
+
28
+ gem.add_dependency("grape")
29
+ gem.add_dependency("yajl-ruby", "~> 1.0")
30
+ gem.add_dependency("fluent-logger")
31
+
32
+ gem.add_development_dependency("ci_reporter")
33
+ gem.add_development_dependency("rack-test")
34
+ gem.add_development_dependency("rake")
35
+ gem.add_development_dependency("rspec")
36
+
37
+ if RUBY_PLATFORM=~ /mswin|mingw|cygwin/
38
+ gem.platform = Gem::Platform::CURRENT
39
+ gem.add_dependency("win32-eventlog")
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steno
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.2
5
+ platform: x86-mingw32
6
+ authors:
7
+ - mpage
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-06 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: yajl-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluent-logger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ci_reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: win32-eventlog
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A thread-safe logging library designed to support multiple log destinations.
126
+ email:
127
+ - mpage@rbcon.com
128
+ executables:
129
+ - steno-prettify
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - bin/steno-prettify
134
+ - lib/steno/codec/base.rb
135
+ - lib/steno/codec/json.rb
136
+ - lib/steno/codec.rb
137
+ - lib/steno/config.rb
138
+ - lib/steno/context.rb
139
+ - lib/steno/core_ext.rb
140
+ - lib/steno/errors.rb
141
+ - lib/steno/http_handler.rb
142
+ - lib/steno/json_prettifier.rb
143
+ - lib/steno/logger.rb
144
+ - lib/steno/log_level.rb
145
+ - lib/steno/record.rb
146
+ - lib/steno/sink/base.rb
147
+ - lib/steno/sink/counter.rb
148
+ - lib/steno/sink/eventlog.rb
149
+ - lib/steno/sink/fluentd.rb
150
+ - lib/steno/sink/io.rb
151
+ - lib/steno/sink/syslog.rb
152
+ - lib/steno/sink.rb
153
+ - lib/steno/tagged_logger.rb
154
+ - lib/steno/version.rb
155
+ - lib/steno.rb
156
+ - LICENSE
157
+ - Rakefile
158
+ - README.md
159
+ - spec/spec_helper.rb
160
+ - spec/support/barrier.rb
161
+ - spec/support/null_sink.rb
162
+ - spec/support/shared_context_specs.rb
163
+ - spec/unit/config_spec.rb
164
+ - spec/unit/context_spec.rb
165
+ - spec/unit/core_ext_spec.rb
166
+ - spec/unit/http_handler_spec.rb
167
+ - spec/unit/json_codec_spec.rb
168
+ - spec/unit/json_prettifier_spec.rb
169
+ - spec/unit/logger_spec.rb
170
+ - spec/unit/log_level_spec.rb
171
+ - spec/unit/record_spec.rb
172
+ - spec/unit/sink/counter_spec.rb
173
+ - spec/unit/sink/eventlog_spec.rb
174
+ - spec/unit/sink/fluentd_spec.rb
175
+ - spec/unit/sink/io_spec.rb
176
+ - spec/unit/sink/syslog_spec.rb
177
+ - spec/unit/steno_spec.rb
178
+ - spec/unit/tagged_logger_spec.rb
179
+ - steno-1.2.1.gem
180
+ - steno.gemspec
181
+ homepage: http://www.cloudfoundry.org
182
+ licenses: []
183
+ metadata: {}
184
+ post_install_message:
185
+ rdoc_options: []
186
+ require_paths:
187
+ - lib
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ! '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ requirements: []
199
+ rubyforge_project:
200
+ rubygems_version: 2.0.7
201
+ signing_key:
202
+ specification_version: 4
203
+ summary: A logging library.
204
+ test_files:
205
+ - spec/spec_helper.rb
206
+ - spec/support/barrier.rb
207
+ - spec/support/null_sink.rb
208
+ - spec/support/shared_context_specs.rb
209
+ - spec/unit/config_spec.rb
210
+ - spec/unit/context_spec.rb
211
+ - spec/unit/core_ext_spec.rb
212
+ - spec/unit/http_handler_spec.rb
213
+ - spec/unit/json_codec_spec.rb
214
+ - spec/unit/json_prettifier_spec.rb
215
+ - spec/unit/logger_spec.rb
216
+ - spec/unit/log_level_spec.rb
217
+ - spec/unit/record_spec.rb
218
+ - spec/unit/sink/counter_spec.rb
219
+ - spec/unit/sink/eventlog_spec.rb
220
+ - spec/unit/sink/fluentd_spec.rb
221
+ - spec/unit/sink/io_spec.rb
222
+ - spec/unit/sink/syslog_spec.rb
223
+ - spec/unit/steno_spec.rb
224
+ - spec/unit/tagged_logger_spec.rb