loggability 0.7.0 → 0.8.0.pre.65

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.
@@ -1,13 +1,9 @@
1
1
  # -*- rspec -*-
2
2
 
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname( __FILE__ ).dirname.parent
6
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
7
- }
3
+ require_relative 'helpers'
8
4
 
9
5
  require 'rspec'
10
- require 'spec/lib/helpers'
6
+
11
7
  require 'loggability'
12
8
  require 'loggability/logger'
13
9
 
@@ -21,19 +17,21 @@ describe Loggability do
21
17
  reset_logging()
22
18
  end
23
19
 
20
+
24
21
  it "is itself a log host for the global logger" do
25
- described_class.logger.should be_a( Loggability::Logger )
26
- described_class.log_hosts.should include( Loggability::GLOBAL_KEY => Loggability )
22
+ expect( described_class.logger ).to be_a( Loggability::Logger )
23
+ expect( described_class.log_hosts ).to include( Loggability::GLOBAL_KEY => Loggability )
27
24
  end
28
25
 
29
26
 
30
27
  describe "version methods" do
31
28
  it "returns a version string if asked" do
32
- described_class.version_string.should =~ /\w+ [\d.]+/
29
+ expect( described_class.version_string ).to match( /\w+ [\d.]+/ )
33
30
  end
34
31
 
35
32
  it "returns a version string with a build number if asked" do
36
- described_class.version_string(true).should =~ /\w+ [\d.]+ \(build [[:xdigit:]]+\)/
33
+ expect( described_class.version_string(true) ).
34
+ to match(/\w+ [\d.]+ \(build [[:xdigit:]]+\)/)
37
35
  end
38
36
  end
39
37
 
@@ -53,40 +51,41 @@ describe Loggability do
53
51
 
54
52
 
55
53
  it "is included in the list of log hosts" do
56
- Loggability.log_hosts.should include( :testing => @class )
54
+ expect( Loggability.log_hosts ).to include( :testing => @class )
57
55
  end
58
56
 
59
57
  it "has an associated Loggability::Logger" do
60
- @class.logger.should be_a( Loggability::Logger )
58
+ expect( @class.logger ).to be_a( Loggability::Logger )
61
59
  end
62
60
 
63
61
  it "has an associated default Loggability::Logger" do
64
- @class.default_logger.should be( @class.logger )
62
+ expect( @class.default_logger ).to be( @class.logger )
65
63
  end
66
64
 
67
65
  it "registers itself with the Loggability module" do
68
- Loggability[ @class ].should be( @class.logger )
66
+ expect( Loggability[@class] ).to be( @class.logger )
69
67
  end
70
68
 
71
69
  it "registers its key with the Loggability module" do
72
- Loggability[ :testing ].should be( @class.logger )
70
+ expect( Loggability[:testing] ).to be( @class.logger )
73
71
  end
74
72
 
75
73
  it "has a proxy for its logger in its instances" do
76
- @class.new.log.logger.should be( @class.logger )
74
+ expect( @class.new.log.logger ).to be( @class.logger )
77
75
  end
78
76
 
79
77
  it "wraps Logger instances assigned as its logger in a Loggability::Logger" do
80
78
  logger = ::Logger.new( $stderr )
81
79
 
82
80
  @class.logger = logger
83
- @class.logger.should be_a( Loggability::Logger )
81
+ expect( @class.logger ).to be_a( Loggability::Logger )
84
82
 
85
83
  @class.log.debug "This shouldn't raise."
86
84
  end
87
85
 
88
86
  end
89
87
 
88
+
90
89
  context "installed in a class as a logging client" do
91
90
 
92
91
  before( :each ) do
@@ -107,28 +106,28 @@ describe Loggability do
107
106
 
108
107
 
109
108
  it "has a proxy for its log host's logger" do
110
- @class.log.logger.should be( @loghost.logger )
109
+ expect( @class.log.logger ).to be( @loghost.logger )
111
110
  end
112
111
 
113
112
  it "is associated with its log host's logger through the Loggability module" do
114
- Loggability[ @class ].should be( @loghost.logger )
113
+ expect( Loggability[@class] ).to be( @loghost.logger )
115
114
  end
116
115
 
117
116
  it "has a proxy for its log host's logger available from its instances" do
118
117
  obj = @class.new
119
- obj.log.logger.should be( @loghost.logger )
118
+ expect( obj.log.logger ).to be( @loghost.logger )
120
119
  end
121
120
 
122
121
 
123
122
  it "is associated with its log host's logger via its instances through the Loggability module" do
124
123
  obj = @class.new
125
- Loggability[ obj ].should be( @loghost.logger )
124
+ expect( Loggability[obj] ).to be( @loghost.logger )
126
125
  end
127
126
 
128
127
  it "propagates its log host key to subclasses" do
129
128
  subclass = Class.new( @class )
130
- subclass.log.logger.should be( @loghost.logger )
131
- Loggability[ subclass ].should be( @loghost.logger )
129
+ expect( subclass.log.logger ).to be( @loghost.logger )
130
+ expect( Loggability[subclass] ).to be( @loghost.logger )
132
131
  end
133
132
 
134
133
  end
@@ -147,19 +146,123 @@ describe Loggability do
147
146
 
148
147
  it "can propagate a logging level to every loghost" do
149
148
  Loggability.level = :warn
150
- Loggability[ @loghost ].level.should == :warn
149
+ expect( Loggability[@loghost].level ).to be( :warn )
151
150
  end
152
151
 
153
152
  it "can propagate an outputter to every loghost" do
154
153
  Loggability.output_to( $stdout )
155
- Loggability[ @loghost ].logdev.dev.should be( $stdout )
154
+ expect( Loggability[@loghost].logdev.dev ).to be( $stdout )
156
155
  end
157
156
 
158
157
  it "can propagate a formatter to every loghost" do
159
158
  Loggability.format_with( :color )
160
- Loggability[ @loghost ].formatter.should be_a( Loggability::Formatter::Color )
159
+ expect( Loggability[@loghost].formatter ).to be_a( Loggability::Formatter::Color )
160
+ end
161
+
162
+
163
+ describe "overrideable behaviors" do
164
+
165
+ before( :each ) do
166
+ @default_output = []
167
+ Loggability.level = :info
168
+ Loggability.output_to( @default_output )
169
+ end
170
+
171
+
172
+ it "can temporarily override where Loggability outputs to while executing a block" do
173
+ tmp_output = []
174
+
175
+ Loggability[ @loghost ].info "Before the override"
176
+ Loggability.outputting_to( tmp_output ) do
177
+ Loggability[ @loghost ].info "During the override"
178
+ end
179
+ Loggability[ @loghost ].info "After the override"
180
+
181
+ expect( @default_output ).to have( 2 ).log_entries
182
+ expect( tmp_output ).to have( 1 ).log_entry
183
+ end
184
+
185
+
186
+ it "can return an object that overrides where Loggability outputs to for any block" do
187
+ tmp_output = []
188
+ with_tmp_logging = Loggability.outputting_to( tmp_output )
189
+
190
+ Loggability[ @loghost ].info "Before the overrides"
191
+ with_tmp_logging.call do
192
+ Loggability[ @loghost ].info "During the first override"
193
+ end
194
+ Loggability[ @loghost ].info "Between overrides"
195
+ with_tmp_logging.call do
196
+ Loggability[ @loghost ].info "During the second override"
197
+ end
198
+ Loggability[ @loghost ].info "After the overrides"
199
+
200
+ expect( @default_output ).to have( 3 ).log_entries
201
+ expect( tmp_output ).to have( 2 ).log_entries
202
+ end
203
+
204
+
205
+ it "can temporarily override what level Loggability logs at while executing a block" do
206
+ Loggability[ @loghost ].debug "Before the override"
207
+ Loggability.with_level( :debug ) do
208
+ Loggability[ @loghost ].debug "During the override"
209
+ end
210
+ Loggability[ @loghost ].debug "After the override"
211
+
212
+ expect( @default_output ).to have( 1 ).log_entry
213
+ end
214
+
215
+
216
+ it "can return an object that overrides what level Loggability logs at for any block" do
217
+ with_debug_logging = Loggability.with_level( :debug )
218
+
219
+ Loggability[ @loghost ].debug "Before the overrides"
220
+ with_debug_logging.call do
221
+ Loggability[ @loghost ].debug "During the first override"
222
+ end
223
+ Loggability[ @loghost ].debug "Between overrides"
224
+ with_debug_logging.call do
225
+ Loggability[ @loghost ].debug "During the second override"
226
+ end
227
+ Loggability[ @loghost ].debug "After the overrides"
228
+
229
+ expect( @default_output ).to have( 2 ).log_entries
230
+ end
231
+
232
+
233
+ it "can temporarily override what formatter loggers use while executing a block" do
234
+ Loggability[ @loghost ].info "Before the override"
235
+ Loggability.formatted_with( :html ) do
236
+ Loggability[ @loghost ].info "During the override"
237
+ end
238
+ Loggability[ @loghost ].info "After the override"
239
+
240
+ expect( @default_output ).to have( 3 ).log_entries
241
+ expect( @default_output.grep(/<div/) ).to have( 1 ).entry
242
+ end
243
+
244
+
245
+ it "can return an object that overrides what formatter loggers use for any block" do
246
+ with_html_logging = Loggability.formatted_with( :html )
247
+
248
+ Loggability[ @loghost ].info "Before the overrides"
249
+ with_html_logging.call do
250
+ Loggability[ @loghost ].info "During the first override"
251
+ end
252
+ Loggability[ @loghost ].info "Between overrides"
253
+ with_html_logging.call do
254
+ Loggability[ @loghost ].info "During the second override"
255
+ end
256
+ Loggability[ @loghost ].info "After the overrides"
257
+
258
+ expect( @default_output ).to have( 5 ).log_entries
259
+ expect( @default_output.grep(/<div/) ).to have( 2 ).log_entries
260
+ end
261
+
262
+
161
263
  end
162
264
 
265
+
163
266
  end
164
267
 
165
268
 
@@ -169,56 +272,58 @@ describe Loggability do
169
272
  File.delete( 'spec-error.log' ) if File.exist?( 'spec-error.log' )
170
273
  end
171
274
 
275
+
276
+ let!( :class1 ) { Class.new {extend Loggability; log_as :class1} }
277
+ let!( :class2 ) { Class.new {extend Loggability; log_as :class2} }
278
+
279
+
172
280
  it "can parse a logging config spec with just a severity" do
173
- Loggability.parse_config_spec( 'debug' ).should == [ 'debug', nil, nil ]
281
+ result = Loggability.parse_config_spec( 'debug' )
282
+ expect( result ).to eq([ 'debug', nil, nil ])
174
283
  end
175
284
 
176
285
  it "can parse a logging config spec with a severity and STDERR" do
177
- Loggability.parse_config_spec( 'fatal STDERR' ).should == [ 'fatal', nil, $stderr ]
286
+ result = Loggability.parse_config_spec( 'fatal STDERR' )
287
+ expect( result ).to eq([ 'fatal', nil, $stderr ])
178
288
  end
179
289
 
180
290
  it "can parse a logging config spec with a severity and STDOUT" do
181
- Loggability.parse_config_spec( 'error STDOUT' ).should == [ 'error', nil, $stdout ]
291
+ result = Loggability.parse_config_spec( 'error STDOUT' )
292
+ expect( result ).to eq([ 'error', nil, $stdout ])
182
293
  end
183
294
 
184
295
  it "can parse a logging config spec with a severity and a path" do
185
- Loggability.parse_config_spec( 'debug /var/log/debug.log' ).
186
- should == [ 'debug', nil, '/var/log/debug.log' ]
296
+ result = Loggability.parse_config_spec( 'debug /var/log/debug.log' )
297
+ expect( result ).to eq([ 'debug', nil, '/var/log/debug.log' ])
187
298
  end
188
299
 
189
300
  it "can parse a logging config spec with a severity and a path with escaped spaces" do
190
- Loggability.parse_config_spec( 'debug /store/media/Stormcrow\\ and\\ Raven/dl.log' ).
191
- should == [ 'debug', nil, '/store/media/Stormcrow\\ and\\ Raven/dl.log' ]
301
+ result = Loggability.parse_config_spec( 'debug /store/media/Stormcrow\\ and\\ Raven/dl.log' )
302
+ expect( result ).to eq([ 'debug', nil, '/store/media/Stormcrow\\ and\\ Raven/dl.log' ])
192
303
  end
193
304
 
194
305
  it "can parse a logging config spec with a severity and a formatter" do
195
- Loggability.parse_config_spec( 'warn (html)' ).
196
- should == [ 'warn', 'html', nil ]
306
+ result = Loggability.parse_config_spec( 'warn (html)' )
307
+ expect( result ).to eq([ 'warn', 'html', nil ])
197
308
  end
198
309
 
199
310
  it "can parse a logging config spec with a severity, a path, and a formatter" do
200
- Loggability.parse_config_spec( 'info /usr/local/www/htdocs/log.html (html)' ).
201
- should == [ 'info', 'html', '/usr/local/www/htdocs/log.html' ]
311
+ result = Loggability.parse_config_spec( 'info /usr/local/www/htdocs/log.html (html)' )
312
+ expect( result ).to eq([ 'info', 'html', '/usr/local/www/htdocs/log.html' ])
202
313
  end
203
314
 
204
315
  it "can configure loghosts via its ::configure method" do
205
- class1 = Class.new { extend Loggability; log_as :class1 }
206
- class2 = Class.new { extend Loggability; log_as :class2 }
207
-
208
316
  config = {'class1' => 'debug (html)', 'class2' => 'error spec-error.log'}
209
317
  Loggability.configure( config )
210
318
 
211
- Loggability[ class1 ].level.should == :debug
212
- Loggability[ class1 ].formatter.should be_a( Loggability::Formatter::HTML )
213
- Loggability[ class2 ].level.should == :error
214
- Loggability[ class2 ].logdev.dev.should be_a( File )
215
- Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
319
+ expect( Loggability[class1].level ).to be( :debug )
320
+ expect( Loggability[class1].formatter ).to be_a( Loggability::Formatter::HTML )
321
+ expect( Loggability[class2].level ).to be( :error )
322
+ expect( Loggability[class2].logdev.dev ).to be_a( File )
323
+ expect( Loggability[class2].logdev.dev.path ).to eq( 'spec-error.log' )
216
324
  end
217
325
 
218
326
  it "can configure loghosts with a Configurability::Config object" do
219
- class1 = Class.new { extend Loggability; log_as :class1 }
220
- class2 = Class.new { extend Loggability; log_as :class2 }
221
-
222
327
  configsource = (<<-"END_CONFIG").gsub( /^\t{3}/, '' )
223
328
  ---
224
329
  logging:
@@ -230,20 +335,20 @@ describe Loggability do
230
335
  config = Configurability::Config.new( configsource )
231
336
  config.install
232
337
 
233
- Loggability[ class1 ].level.should == :debug
234
- Loggability[ class1 ].formatter.should be_a( Loggability::Formatter::HTML )
235
- Loggability[ class2 ].level.should == :error
236
- Loggability[ class2 ].logdev.dev.should be_a( File )
237
- Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
338
+ expect( Loggability[class1].level ).to be( :debug )
339
+ expect( Loggability[class1].formatter ).to be_a( Loggability::Formatter::HTML )
340
+ expect( Loggability[class2].level ).to be( :error )
341
+ expect( Loggability[class2].logdev.dev ).to be_a( File )
342
+ expect( Loggability[class2].logdev.dev.path ).to eq( 'spec-error.log' )
238
343
  end
239
344
 
240
345
  it "can configure all loghosts with a config key of __default__" do
241
346
  Loggability.configure( '__default__' => 'debug STDERR (html)' )
242
347
 
243
- all_loggers = Loggability.log_hosts.values.map( &:logger )
244
- all_loggers.all? {|lh| lh.level == :debug }.should be_true()
245
- all_loggers.all? {|lh| lh.formatter.class == Loggability::Formatter::HTML }.should be_true()
246
- all_loggers.all? {|lh| lh.logdev.dev.should == $stderr }.should be_true()
348
+ loggers = Loggability.log_hosts.values.map( &:logger )
349
+ expect( loggers.map(&:level) ).to all_be( :debug )
350
+ expect( loggers.map(&:formatter) ).to all_be_a( Loggability::Formatter::HTML )
351
+ expect( loggers.map(&:logdev).map(&:dev) ).to all_be( $stderr )
247
352
  end
248
353
 
249
354
  it "raises an error if configured with a logspec with an invalid severity" do
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- k��}����xR��};{
2
- X�Q
1
+ ����D��`����<!y_Ѯ��/S������([�ST �u��#HmM|� ��n�>���k�s�Y����
2
+ =�Y4�������3��N��f���#�?��n$S�ϓi��X�$A�A�
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0.pre.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -30,7 +30,7 @@ cert_chain:
30
30
  6mKCwjpegytE0oifXfF8k75A9105cBnNiMZOe1tXiqYc/exCgWvbggurzDOcRkZu
31
31
  /YSusaiDXHKU2O3Akc3htA==
32
32
  -----END CERTIFICATE-----
33
- date: 2013-08-24 00:00:00.000000000 Z
33
+ date: 2013-10-07 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: hoe-mercurial
@@ -88,6 +88,20 @@ dependencies:
88
88
  - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0.3'
91
+ - !ruby/object:Gem::Dependency
92
+ name: hoe-bundler
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '1.2'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: '1.2'
91
105
  - !ruby/object:Gem::Dependency
92
106
  name: simplecov
93
107
  requirement: !ruby/object:Gem::Requirement
@@ -162,13 +176,17 @@ files:
162
176
  - lib/loggability/formatter/color.rb
163
177
  - lib/loggability/formatter/default.rb
164
178
  - lib/loggability/formatter/html.rb
179
+ - lib/loggability/logclient.rb
165
180
  - lib/loggability/logger.rb
181
+ - lib/loggability/loghost.rb
182
+ - lib/loggability/override.rb
166
183
  - lib/loggability/spechelpers.rb
167
- - spec/lib/helpers.rb
184
+ - spec/helpers.rb
168
185
  - spec/loggability/formatter/color_spec.rb
169
186
  - spec/loggability/formatter/html_spec.rb
170
187
  - spec/loggability/formatter_spec.rb
171
188
  - spec/loggability/logger_spec.rb
189
+ - spec/loggability/override_spec.rb
172
190
  - spec/loggability_spec.rb
173
191
  - .gemtest
174
192
  homepage: http://deveiate.org/projects/loggability
@@ -185,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
203
  requirements:
186
204
  - - '>='
187
205
  - !ruby/object:Gem::Version
188
- version: 1.8.7
206
+ version: 1.9.3
189
207
  required_rubygems_version: !ruby/object:Gem::Requirement
190
208
  requirements:
191
209
  - - '>='
@@ -193,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
211
  version: '0'
194
212
  requirements: []
195
213
  rubyforge_project: loggability
196
- rubygems_version: 2.0.5
214
+ rubygems_version: 2.0.6
197
215
  signing_key:
198
216
  specification_version: 4
199
217
  summary: A composable logging system built on the standard Logger library
metadata.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- 8��-
2
- ��[^�񶴱�ԈW��Ameo8ٞ�G��璷̒㔌���4��WM.�8�����dV���.�%����l;��Z頯���\�SN�#�o���E
3
- ?.����l
1
+ �½�Q! 5�Scᮑ�Ҿ��qu?���r�{�Ӎ'�������zz
2
+ �IJ�!?��������ϚwqϮ��h�c��Y�g������������<F�����7��6~Ʉ�O���R�����(�aM�~m����E�� �3S�D6K���q1��c����^���m�n�d�?��"��uQ/�!r�GW*����0o�T}�-�jcY祉��ÛC�V'�+x|M��a�ښ~!�-8
3
+ F-����f�`������
data/spec/lib/helpers.rb DELETED
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # vim: set nosta noet ts=4 sw=4:
3
- # encoding: utf-8
4
-
5
- BEGIN {
6
- require 'pathname'
7
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
8
-
9
- libdir = basedir + "lib"
10
-
11
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
12
- }
13
-
14
- # SimpleCov test coverage reporting; enable this using the :coverage rake task
15
- if ENV['COVERAGE']
16
- $stderr.puts "\n\n>>> Enabling coverage report.\n\n"
17
- require 'simplecov'
18
- SimpleCov.start do
19
- add_filter 'spec'
20
- end
21
- end
22
-
23
- begin
24
- require 'configurability'
25
- rescue LoadError
26
- end
27
-
28
- require 'loggability' unless defined?( Loggability )
29
- require 'loggability/spechelpers'
30
-
31
-
32
- ### Mock with RSpec
33
- RSpec.configure do |c|
34
- c.mock_with( :rspec )
35
- c.treat_symbols_as_metadata_keys_with_true_values = true
36
-
37
- c.include( Loggability::SpecHelpers )
38
- c.filter_run_excluding( :configurability ) unless defined?( Configurability )
39
- end
40
-