steno 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe Steno::Sink::Syslog do
4
+ describe "#add_record" do
5
+ it "should append an encoded record with the correct priority" do
6
+ identity = "test"
7
+
8
+ syslog = mock("syslog")
9
+ Syslog.should_receive(:open) \
10
+ .with(identity, Syslog::LOG_PID, Syslog::LOG_USER) \
11
+ .and_return(syslog)
12
+
13
+ sink = Steno::Sink::Syslog.instance
14
+ sink.open(identity)
15
+
16
+ record = Steno::Record.new("test", :info, "hello")
17
+
18
+ codec = mock("codec")
19
+ codec.should_receive(:encode_record).with(record).and_return("test")
20
+ sink.codec = codec
21
+
22
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%s", "test")
23
+
24
+ sink.add_record(record)
25
+ end
26
+ end
27
+ 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.gemspec ADDED
@@ -0,0 +1,26 @@
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
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "steno"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Steno::VERSION
18
+
19
+ gem.add_dependency("grape")
20
+ gem.add_dependency("yajl-ruby")
21
+
22
+ gem.add_development_dependency("ci_reporter")
23
+ gem.add_development_dependency("rack-test")
24
+ gem.add_development_dependency("rake")
25
+ gem.add_development_dependency("rspec")
26
+ end
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: steno
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mpage
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: grape
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: yajl-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ci_reporter
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: A thread-safe logging library designed to support multiple log destinations.
111
+ email:
112
+ - mpage@rbcon.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - LICENSE
120
+ - README.md
121
+ - Rakefile
122
+ - lib/steno.rb
123
+ - lib/steno/codec.rb
124
+ - lib/steno/codec/base.rb
125
+ - lib/steno/codec/json.rb
126
+ - lib/steno/config.rb
127
+ - lib/steno/context.rb
128
+ - lib/steno/core_ext.rb
129
+ - lib/steno/errors.rb
130
+ - lib/steno/http_handler.rb
131
+ - lib/steno/log_level.rb
132
+ - lib/steno/logger.rb
133
+ - lib/steno/record.rb
134
+ - lib/steno/sink.rb
135
+ - lib/steno/sink/base.rb
136
+ - lib/steno/sink/io.rb
137
+ - lib/steno/sink/syslog.rb
138
+ - lib/steno/tagged_logger.rb
139
+ - lib/steno/version.rb
140
+ - spec/core_ext_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/support/barrier.rb
143
+ - spec/support/null_sink.rb
144
+ - spec/support/shared_context_specs.rb
145
+ - spec/unit/context_spec.rb
146
+ - spec/unit/http_handler_spec.rb
147
+ - spec/unit/io_sink_spec.rb
148
+ - spec/unit/json_codec_spec.rb
149
+ - spec/unit/log_level_spec.rb
150
+ - spec/unit/logger_spec.rb
151
+ - spec/unit/record_spec.rb
152
+ - spec/unit/steno_spec.rb
153
+ - spec/unit/syslog_sink_spec.rb
154
+ - spec/unit/tagged_logger_spec.rb
155
+ - steno.gemspec
156
+ homepage: http://www.cloudfoundry.org
157
+ licenses: []
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ none: false
164
+ requirements:
165
+ - - ! '>='
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 1.8.23
177
+ signing_key:
178
+ specification_version: 3
179
+ summary: A logging library.
180
+ test_files:
181
+ - spec/core_ext_spec.rb
182
+ - spec/spec_helper.rb
183
+ - spec/support/barrier.rb
184
+ - spec/support/null_sink.rb
185
+ - spec/support/shared_context_specs.rb
186
+ - spec/unit/context_spec.rb
187
+ - spec/unit/http_handler_spec.rb
188
+ - spec/unit/io_sink_spec.rb
189
+ - spec/unit/json_codec_spec.rb
190
+ - spec/unit/log_level_spec.rb
191
+ - spec/unit/logger_spec.rb
192
+ - spec/unit/record_spec.rb
193
+ - spec/unit/steno_spec.rb
194
+ - spec/unit/syslog_sink_spec.rb
195
+ - spec/unit/tagged_logger_spec.rb