loggability 0.8.1 → 0.9.0.pre.73

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd32c093968b3ea5843c6697f92de513c0b0cf86
4
- data.tar.gz: 77d614d2a678792322dc0662d49fb18d2a31f158
3
+ metadata.gz: ca197a7e5f2104cf971a2f8f416b3a4d6fa581db
4
+ data.tar.gz: 6be12107ba29eb58a9e6ae9570faa7535d5e40f4
5
5
  SHA512:
6
- metadata.gz: d66083a3f8fa879ebfec74866d630706b47bf1a1db88a8bb073274c6d447350e85d45dfcf61ca229623dfeb89dab1a76fc2e7f0472b1d6f5e36b3829865e67bf
7
- data.tar.gz: 774215025c07daf8c795908f9305f9f6ee4eb51bcb4c29ba117e50c22186f689e4a8a83f393715d8f1bd09df49132e5d9e6c9c55152835ff7769c7c1f0d711e7
6
+ metadata.gz: 41a0aeb5f7633c34e28f294c03750dc4d7f4be00178f9c7383f98aa877295c1825c4b12dc1c71a91d8dc1149371100284293fd4b9652eb23b841e78f543db58a
7
+ data.tar.gz: d413ef02c1479adc8dfb8579135b720a956c93990bf084d1e6c1ac3f2e4608513f807cc3de41f6f30ddc01bf4549998dbd9c6f3e7e17a157961b7eb518db0fed
checksums.yaml.gz.sig CHANGED
Binary file
data/Manifest.txt CHANGED
@@ -20,4 +20,5 @@ spec/loggability/formatter/html_spec.rb
20
20
  spec/loggability/formatter_spec.rb
21
21
  spec/loggability/logger_spec.rb
22
22
  spec/loggability/override_spec.rb
23
+ spec/loggability/spechelpers_spec.rb
23
24
  spec/loggability_spec.rb
data/README.rdoc CHANGED
@@ -45,43 +45,6 @@ An example:
45
45
  Loggability.level = :info
46
46
 
47
47
 
48
- === Configurability
49
-
50
- Loggability has support for the Configurability[https://rubygems.org/gems/configurability]
51
- library, which does the same thing for configuration that Loggability does for
52
- logging.
53
-
54
- You can configure all registered loggers from the 'logging' section of the config:
55
-
56
- logging:
57
- __default__: warn STDERR
58
- mongrel2: info STDOUT (html)
59
- strelka: debug (html)
60
- inversion: error /var/log/templating.log (default)
61
-
62
- The format of the value of each logger is:
63
-
64
- SEVERITY [TARGET] [(FORMAT)]
65
-
66
- where:
67
-
68
- [+SEVERITY+]
69
- The log level; one of: +debug+, +info+, +warn+, +error+, or +fatal+
70
- [+TARGET+]
71
- The destination for log messages. This can be the path to a log file, or
72
- one of <tt>'STDOUT'</tt> or <tt>'STDERR'</tt>, which get mapped to the
73
- equivalent filehandle. Optional.
74
- [+FORMAT+]
75
- The name of one of the formatters. Loggability comes with +default+ (plaintext),
76
- +color+ (ANSI colored text), and +html+ formatters.
77
-
78
- If the special key <tt>__default__</tt> is included, its config will be used to set
79
- global defaults before the individual configs are applied.
80
-
81
- If either of the optional values is unspecified, it is left unchanged from what it
82
- was before configuration.
83
-
84
-
85
48
  == Prerequisites
86
49
 
87
50
  * Ruby 1.9.3 or better, Rubinius 2.0 or better
@@ -216,24 +179,121 @@ Loggability has a few ways of doing that:
216
179
 
217
180
  # Log only fatal errors...
218
181
  Loggability.with_level( :fatal ) do
219
- ...
220
- end
182
+ ...
183
+ end
221
184
 
222
185
  # Log everything to an array for the block
223
186
  logs = []
224
- Loggability.outputting_to( logs ) do
225
- ...
226
- end
187
+ Loggability.outputting_to( logs ) do
188
+ ...
189
+ end
227
190
 
228
- # Log using the HTML formatter
229
- Loggability.formatted_with( :html ) do
230
- ...
231
- end
191
+ # Log using the HTML formatter
192
+ Loggability.formatted_with( :html ) do
193
+ ...
194
+ end
232
195
 
233
196
  # Or chain them together:
234
197
  Loggability.with_level( :debug ).outputting_to( $stderr ).formatted_with( :color ) do
235
- Client.connect!
236
- end
198
+ Client.connect!
199
+ end
200
+
201
+
202
+ === Configurability
203
+
204
+ Loggability has support for the Configurability[https://rubygems.org/gems/configurability]
205
+ library, which does the same thing for configuration that Loggability does for
206
+ logging.
207
+
208
+ You can configure all registered loggers from the 'logging' section of the config:
209
+
210
+ logging:
211
+ __default__: warn STDERR
212
+ mongrel2: info STDOUT (html)
213
+ strelka: debug (html)
214
+ inversion: error /var/log/templating.log (default)
215
+
216
+ The format of the value of each logger is:
217
+
218
+ SEVERITY [TARGET] [(FORMAT)]
219
+
220
+ where:
221
+
222
+ [+SEVERITY+]
223
+ The log level; one of: +debug+, +info+, +warn+, +error+, or +fatal+
224
+ [+TARGET+]
225
+ The destination for log messages. This can be the path to a log file, or
226
+ one of <tt>'STDOUT'</tt> or <tt>'STDERR'</tt>, which get mapped to the
227
+ equivalent filehandle. Optional.
228
+ [+FORMAT+]
229
+ The name of one of the formatters. Loggability comes with +default+ (plaintext),
230
+ +color+ (ANSI colored text), and +html+ formatters. Optional.
231
+
232
+ If the special key <tt>__default__</tt> is included, its config will be used to set
233
+ global defaults before the individual configs are applied.
234
+
235
+ If either of the optional values is unspecified, it is left unchanged from what it
236
+ was before configuration.
237
+
238
+
239
+ === RSpec Helpers
240
+
241
+ Loggability includes a couple of helper functions for RSpec that allow you to control
242
+ log levels for particular specs.
243
+
244
+ To use it, require <tt>loggability/spechelpers</tt> in your specs (we put it in the
245
+ spec helpers file) and then include the helpers from your RSpec config:
246
+
247
+ require 'loggability/spechelpers'
248
+ RSpec.configure do |c|
249
+ # ...
250
+ c.include( Loggability::SpecHelpers )
251
+ end
252
+
253
+ This will install a before and after `:all` hook to set the logging levels before each
254
+ example group and then reset it before moving on to the next group.
255
+
256
+ You can also access the bodies of those hooks manually:
257
+
258
+ setup_logging( level=:fatal )
259
+ reset_logging()
260
+
261
+ The helpers also allow you to set logging levels for a whole example group, for
262
+ particular contexts, or even for individual examples using RSpec's metadata hash
263
+ syntax:
264
+
265
+ # Set logging to 'error' level for each example in this group
266
+ describe MyClass, logging: :error do
267
+
268
+ # ...but for examples in this context, set it to 'fatal'
269
+ context 'created with a target', log: :fatal do
270
+
271
+ # ...except for this one, which logs at 'debug' level
272
+ it "does something to it", logging: :debug do
273
+
274
+ end
275
+
276
+ it "does some other stuff, too"
277
+
278
+ end
279
+
280
+ end
281
+
282
+ The {setup_logging}[rdoc-ref:Loggability::SpecHelpers.setup_logging] helper
283
+ also provides support for displaying the logs inline with spec formatters for
284
+ which outputting the logs to STDERR isn't optimal. The only one that's
285
+ currently uses it is the
286
+ {'webkit' formatter}[https://rubygems.org/gems/rspec-formatter-webkit], but
287
+ it should be easy to adapt to other HTML displays as well.
288
+
289
+ It looks for either an +HTML_LOGGING+ environment variable, or for the
290
+ +TM_FILENAME+ variable to be set to a filename that ends with '_spec.rb'
291
+ (for Textmate's rspec runner). In either of those conditions, it will set
292
+ up logging output to go to a thread-local Array called 'logger-output',
293
+ log using the 'html' formatter, and set the log level to 'debug'.
294
+
295
+ This can be used to append logs to each example when the formatter
296
+ builds the output.
237
297
 
238
298
 
239
299
  == Contributing
data/Rakefile CHANGED
@@ -47,3 +47,16 @@ task :coverage do
47
47
  Rake::Task[:spec].invoke
48
48
  end
49
49
 
50
+ # Use the fivefish formatter for docs generated from development checkout
51
+ if File.directory?( '.hg' )
52
+ require 'rdoc/task'
53
+
54
+ Rake::Task[ 'docs' ].clear
55
+ RDoc::Task.new( 'docs' ) do |rdoc|
56
+ rdoc.main = "README.rdoc"
57
+ rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
58
+ rdoc.generator = :fivefish
59
+ rdoc.rdoc_dir = 'doc'
60
+ end
61
+ end
62
+
@@ -6,19 +6,50 @@ require 'loggability' unless defined?( Loggability )
6
6
 
7
7
  # Some helper functions for testing. Usage:
8
8
  #
9
+ # # in spec_helpers.rb
9
10
  # RSpec.configure do |c|
10
- # c.include( Loggability::SpecHelpers )
11
+ # c.include( Loggability::SpecHelpers )
11
12
  # end
12
13
  #
13
- # describe MyClass do
14
- # before( :all ) { setup_logging }
15
- # after( :all ) { reset_logging }
14
+ # # in my_class_spec.rb; set logging level to :error
15
+ # describe MyClass, log: :error do
16
16
  #
17
- # # ...
17
+ # # Except for this example, which logs at :debug
18
+ # it "does something", log: :debug do
19
+ # # anything the spec does here will be logged at :debug
20
+ # end
21
+ #
22
+ # it "does something else" do
23
+ # # but this will use the :error level from the 'describe'
24
+ # end
18
25
  #
19
26
  # end
27
+ #
20
28
  module Loggability::SpecHelpers
21
29
 
30
+ ### Inclusion callback -- install some hooks that set up logging
31
+ ### for RSpec specs.
32
+ def self::included( context )
33
+ context.around( :each ) do |example|
34
+ if level = (example.metadata[:log] || example.metadata[:logging])
35
+ Loggability.with_level( level, &example )
36
+ else
37
+ example.run
38
+ end
39
+ end
40
+
41
+ context.before( :all ) do
42
+ setup_logging()
43
+ end
44
+
45
+ context.after( :all ) do
46
+ reset_logging()
47
+ end
48
+
49
+ super
50
+ end
51
+
52
+
22
53
  ### Reset the logging subsystem to its default state.
23
54
  def reset_logging
24
55
  Loggability.formatter = nil
data/lib/loggability.rb CHANGED
@@ -9,7 +9,7 @@ require 'date'
9
9
  module Loggability
10
10
 
11
11
  # Package version constant
12
- VERSION = '0.8.1'
12
+ VERSION = '0.9.0.pre.73'
13
13
 
14
14
  # VCS revision
15
15
  REVISION = %q$Revision: db603bf7b399 $
data/spec/helpers.rb CHANGED
@@ -112,5 +112,6 @@ RSpec.configure do |c|
112
112
  c.include( SpecHelpers )
113
113
  c.include( Loggability::SpecHelpers )
114
114
  c.filter_run_excluding( :configurability ) unless defined?( Configurability )
115
+
115
116
  end
116
117
 
@@ -0,0 +1,16 @@
1
+ # -*- rspec -*-
2
+
3
+ require_relative '../helpers'
4
+
5
+ require 'tempfile'
6
+ require 'rspec'
7
+
8
+ require 'loggability/spechelpers'
9
+
10
+
11
+ describe Loggability::SpecHelpers do
12
+
13
+ # Not sure how to test this stuff
14
+
15
+ end
16
+
data.tar.gz.sig CHANGED
Binary file
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.8.1
4
+ version: 0.9.0.pre.73
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-10-09 00:00:00.000000000 Z
33
+ date: 2013-11-23 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: hoe-mercurial
@@ -187,6 +187,7 @@ files:
187
187
  - spec/loggability/formatter_spec.rb
188
188
  - spec/loggability/logger_spec.rb
189
189
  - spec/loggability/override_spec.rb
190
+ - spec/loggability/spechelpers_spec.rb
190
191
  - spec/loggability_spec.rb
191
192
  - .gemtest
192
193
  homepage: http://deveiate.org/projects/loggability
@@ -206,12 +207,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
207
  version: 1.9.3
207
208
  required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  requirements:
209
- - - '>='
210
+ - - '>'
210
211
  - !ruby/object:Gem::Version
211
- version: '0'
212
+ version: 1.3.1
212
213
  requirements: []
213
214
  rubyforge_project: loggability
214
- rubygems_version: 2.0.6
215
+ rubygems_version: 2.1.10
215
216
  signing_key:
216
217
  specification_version: 4
217
218
  summary: A composable logging system built on the standard Logger library
metadata.gz.sig CHANGED
Binary file