loggability 0.8.1 → 0.9.0.pre.73
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +108 -48
- data/Rakefile +13 -0
- data/lib/loggability/spechelpers.rb +36 -5
- data/lib/loggability.rb +1 -1
- data/spec/helpers.rb +1 -0
- data/spec/loggability/spechelpers_spec.rb +16 -0
- data.tar.gz.sig +0 -0
- metadata +6 -5
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca197a7e5f2104cf971a2f8f416b3a4d6fa581db
|
4
|
+
data.tar.gz: 6be12107ba29eb58a9e6ae9570faa7535d5e40f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a0aeb5f7633c34e28f294c03750dc4d7f4be00178f9c7383f98aa877295c1825c4b12dc1c71a91d8dc1149371100284293fd4b9652eb23b841e78f543db58a
|
7
|
+
data.tar.gz: d413ef02c1479adc8dfb8579135b720a956c93990bf084d1e6c1ac3f2e4608513f807cc3de41f6f30ddc01bf4549998dbd9c6f3e7e17a157961b7eb518db0fed
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Manifest.txt
CHANGED
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
|
-
|
182
|
+
...
|
183
|
+
end
|
221
184
|
|
222
185
|
# Log everything to an array for the block
|
223
186
|
logs = []
|
224
|
-
|
225
|
-
|
226
|
-
|
187
|
+
Loggability.outputting_to( logs ) do
|
188
|
+
...
|
189
|
+
end
|
227
190
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
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
|
-
|
236
|
-
|
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
|
-
#
|
11
|
+
# c.include( Loggability::SpecHelpers )
|
11
12
|
# end
|
12
13
|
#
|
13
|
-
#
|
14
|
-
#
|
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
data/spec/helpers.rb
CHANGED
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.
|
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-
|
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:
|
212
|
+
version: 1.3.1
|
212
213
|
requirements: []
|
213
214
|
rubyforge_project: loggability
|
214
|
-
rubygems_version: 2.
|
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
|