loggability 0.13.0 → 0.14.0
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.tar.gz.sig +0 -0
- data/ChangeLog +48 -1
- data/History.rdoc +7 -0
- data/README.rdoc +12 -1
- data/lib/loggability.rb +36 -7
- data/lib/loggability/override.rb +59 -12
- data/spec/loggability/override_spec.rb +88 -1
- data/spec/loggability_spec.rb +84 -28
- metadata +29 -24
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c536cf9f22b05e0acc0b3cb3e1f4202d19ab2c2
|
4
|
+
data.tar.gz: 5262aca5aedb923da7883b756a1d0b6c664f13ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53a0d4ea43fd572540705175b95e8bd1f797ebbc9059df328b17fdaf72fe76c8e2077bd47f729c02e430234872eeb234c6ec7d2c65466693af375d50dee05e0
|
7
|
+
data.tar.gz: 920507dfb7ef2dff0105baae0d0da205e59e5e705bf5da5cb3149e17eabd80fffde576c9bf63a79cdb633a989d0d73f0bbebd82f637284b35c88690240058dd7
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,8 +1,55 @@
|
|
1
|
+
2017-01-30 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* README.rdoc, lib/loggability.rb, lib/loggability/override.rb,
|
4
|
+
loggability.gemspec, spec/loggability/override_spec.rb,
|
5
|
+
spec/loggability_spec.rb:
|
6
|
+
Allow overriding log hosts for a block
|
7
|
+
[f8dc613a7b78] [tip]
|
8
|
+
|
9
|
+
2017-01-16 Michael Granger <ged@FaerieMUD.org>
|
10
|
+
|
11
|
+
* Merge with 5a726b7f87db
|
12
|
+
[f155ecfa1599] [github/master]
|
13
|
+
|
14
|
+
* README.md:
|
15
|
+
Backing out bitbucket README crap
|
16
|
+
[bdf3a19c7bd5]
|
17
|
+
|
18
|
+
2016-12-28 Michael Granger <ged@faeriemud.org>
|
19
|
+
|
20
|
+
* README.md:
|
21
|
+
README.md edited online with Bitbucket
|
22
|
+
[a70fe4d1f1ce]
|
23
|
+
|
24
|
+
2017-01-16 Mahlon E. Smith <mahlon@martini.nu>
|
25
|
+
|
26
|
+
* .hgsigs, .hgtags:
|
27
|
+
Merge accidental branching.
|
28
|
+
[5a726b7f87db]
|
29
|
+
|
1
30
|
2017-01-16 Mahlon E. Smith <mahlon@laika.com>
|
2
31
|
|
32
|
+
* .hgtags:
|
33
|
+
Added tag v0.13.0 for changeset 9dadd26fcb41
|
34
|
+
[f1b3d8191c22]
|
35
|
+
|
36
|
+
* .hgsigs:
|
37
|
+
Added signature for changeset 2676e38c8850
|
38
|
+
[9dadd26fcb41] [v0.13.0]
|
39
|
+
|
3
40
|
* History.rdoc, Rakefile, lib/loggability.rb:
|
4
41
|
Just a bump for the Configurability dependency.
|
5
|
-
[2676e38c8850]
|
42
|
+
[2676e38c8850]
|
43
|
+
|
44
|
+
2016-12-28 Michael Granger <ged@FaerieMUD.org>
|
45
|
+
|
46
|
+
* .hgtags:
|
47
|
+
Added tag v0.12.0 for changeset afbc62f64869
|
48
|
+
[724e4945be75]
|
49
|
+
|
50
|
+
* .hgsigs:
|
51
|
+
Added signature for changeset f4e0960bd29c
|
52
|
+
[afbc62f64869] [v0.12.0]
|
6
53
|
|
7
54
|
2016-12-14 Michael Granger <ged@FaerieMUD.org>
|
8
55
|
|
data/History.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -198,6 +198,17 @@ Loggability has a few ways of doing that:
|
|
198
198
|
Client.connect!
|
199
199
|
end
|
200
200
|
|
201
|
+
You can also make the override only apply to the loggers for a subset of log hosts:
|
202
|
+
|
203
|
+
# Log only fatal errors on the loggers for the specified two classes
|
204
|
+
Loggability.with_level( :fatal ).for_loggers( ACME::Model, ACME::Adapter ) do
|
205
|
+
ACME.start_up
|
206
|
+
end
|
207
|
+
|
208
|
+
# Debug a particular class:
|
209
|
+
Loggability.with_level( :debug ).for_logger( ACME::Server ) do
|
210
|
+
ACME.start_up
|
211
|
+
end
|
201
212
|
|
202
213
|
=== Configurability
|
203
214
|
|
@@ -312,7 +323,7 @@ and generate the API documentation.
|
|
312
323
|
|
313
324
|
== License
|
314
325
|
|
315
|
-
Copyright (c) 2012-
|
326
|
+
Copyright (c) 2012-2017, Michael Granger
|
316
327
|
All rights reserved.
|
317
328
|
|
318
329
|
Redistribution and use in source and binary forms, with or without
|
data/lib/loggability.rb
CHANGED
@@ -9,10 +9,10 @@ require 'date'
|
|
9
9
|
module Loggability
|
10
10
|
|
11
11
|
# Package version constant
|
12
|
-
VERSION = '0.
|
12
|
+
VERSION = '0.14.0'
|
13
13
|
|
14
14
|
# VCS revision
|
15
|
-
REVISION = %q$Revision:
|
15
|
+
REVISION = %q$Revision: 500260d36bfb $
|
16
16
|
|
17
17
|
# The key for the global logger (Loggability's own logger)
|
18
18
|
GLOBAL_KEY = :__global__
|
@@ -113,6 +113,19 @@ module Loggability
|
|
113
113
|
end
|
114
114
|
|
115
115
|
|
116
|
+
### Return the log host for +object+, if any. Raises an ArgumentError if the +object+
|
117
|
+
### doesn't have an associated log host.
|
118
|
+
def self::log_host_for( object )
|
119
|
+
key = self.log_host_key_for( object )
|
120
|
+
key ||= GLOBAL_KEY
|
121
|
+
|
122
|
+
loghost = self.log_hosts[ key ] or
|
123
|
+
raise ArgumentError, "no log host set up for %p yet." % [ key ]
|
124
|
+
|
125
|
+
return loghost
|
126
|
+
end
|
127
|
+
|
128
|
+
|
116
129
|
### Returns +true+ if there is a log host associated with the given +object+.
|
117
130
|
def self::log_host?( object )
|
118
131
|
key = self.log_host_key_for( object ) or return false
|
@@ -122,11 +135,7 @@ module Loggability
|
|
122
135
|
|
123
136
|
### Return the Loggability::Logger for the loghost associated with +logclient+.
|
124
137
|
def self::[]( logclient )
|
125
|
-
|
126
|
-
key ||= GLOBAL_KEY
|
127
|
-
|
128
|
-
loghost = self.log_hosts[ key ] or
|
129
|
-
raise ArgumentError, "no log host set up for %p yet." % [ key ]
|
138
|
+
loghost = self.log_host_for( logclient )
|
130
139
|
return loghost.logger
|
131
140
|
end
|
132
141
|
|
@@ -247,6 +256,26 @@ module Loggability
|
|
247
256
|
end
|
248
257
|
|
249
258
|
|
259
|
+
### Aggregate method: override one or more settings for the duration of the +block+ for
|
260
|
+
### only the given +hosts+. If no +block+ is given returns a
|
261
|
+
### Loggability::Override object that will override the specified log hosts whenever its
|
262
|
+
### +#call+ method is called.
|
263
|
+
def self::for_logger( *hosts, &block )
|
264
|
+
override = Loggability::Override.for_logger( *hosts )
|
265
|
+
|
266
|
+
if block
|
267
|
+
return override.call( &block )
|
268
|
+
else
|
269
|
+
return override
|
270
|
+
end
|
271
|
+
end
|
272
|
+
class << self
|
273
|
+
alias_method :for_loggers, :for_logger
|
274
|
+
alias_method :for_log_host, :for_logger
|
275
|
+
alias_method :for_log_hosts, :for_logger
|
276
|
+
end
|
277
|
+
|
278
|
+
|
250
279
|
#
|
251
280
|
# :section: LogHost API
|
252
281
|
#
|
data/lib/loggability/override.rb
CHANGED
@@ -43,6 +43,14 @@ class Loggability::Override
|
|
43
43
|
end
|
44
44
|
|
45
45
|
|
46
|
+
### Set up an Override that will only apply to the specified +log_hosts+. If called
|
47
|
+
### with a +block+, call #call immediately on the Override with the block and return
|
48
|
+
## the result of that instead.
|
49
|
+
def self::for_logger( *log_hosts, &block )
|
50
|
+
return self.new( log_hosts: log_hosts, &block )
|
51
|
+
end
|
52
|
+
|
53
|
+
|
46
54
|
### Create a new Override with the specified +settings+ that will be applied
|
47
55
|
### during a call to #call, and then reverted when #call returns. Valid +settings+
|
48
56
|
### are:
|
@@ -51,22 +59,26 @@ class Loggability::Override
|
|
51
59
|
### Set the level of all Loggers to the value.
|
52
60
|
### [:logdev]
|
53
61
|
### Set the destination log device of all Loggers to the value.
|
62
|
+
### [:log_hosts]
|
63
|
+
### Set the affected log hosts to the value.
|
54
64
|
### [:formatter]
|
55
65
|
### Set the formatter for all Loggers to the value (a Loggability::Formatter).
|
56
66
|
###
|
57
67
|
def initialize( settings={} )
|
58
68
|
super()
|
59
69
|
|
70
|
+
@log_hosts = settings.delete( :log_hosts )
|
60
71
|
@settings = settings
|
61
|
-
@overridden_settings =
|
72
|
+
@overridden_settings = nil
|
62
73
|
end
|
63
74
|
|
64
75
|
|
65
76
|
### Copy constructor -- make copies of the internal data structures
|
66
77
|
### when duplicated.
|
67
78
|
def initialize_copy( original )
|
79
|
+
@log_hosts = original.log_hosts.dup if original.log_hosts
|
68
80
|
@settings = original.settings.dup
|
69
|
-
@overridden_settings =
|
81
|
+
@overridden_settings = nil
|
70
82
|
end
|
71
83
|
|
72
84
|
|
@@ -74,13 +86,20 @@ class Loggability::Override
|
|
74
86
|
public
|
75
87
|
######
|
76
88
|
|
89
|
+
##
|
77
90
|
# The Override's settings Hash (the settings that will be applied during
|
78
91
|
# an overridden #call).
|
79
92
|
attr_reader :settings
|
80
93
|
|
94
|
+
##
|
81
95
|
# The original settings preserved by the Override during a call to #call,
|
82
96
|
# keyed by the logger they belong to.
|
83
|
-
|
97
|
+
attr_accessor :overridden_settings
|
98
|
+
|
99
|
+
##
|
100
|
+
# The log hosts the Override will be applied to during an overridden
|
101
|
+
# #call. If this is +nil+, all log hosts will be affected.
|
102
|
+
attr_accessor :log_hosts
|
84
103
|
|
85
104
|
|
86
105
|
### Call the provided block with configured overrides applied, and then restore
|
@@ -118,14 +137,24 @@ class Loggability::Override
|
|
118
137
|
end
|
119
138
|
|
120
139
|
|
140
|
+
### Return a clone of the receiving Override with its log hosts set to +hosts+
|
141
|
+
### (instead of affecting all registered log hosts)
|
142
|
+
def for_logger( *hosts, &block )
|
143
|
+
raise ArgumentError, "no log hosts given" if hosts.empty?
|
144
|
+
return self.clone_with( log_hosts: hosts, &block )
|
145
|
+
end
|
146
|
+
alias_method :for_loggers, :for_logger
|
147
|
+
|
148
|
+
|
121
149
|
### Return the object as a human-readable string suitable for debugging.
|
122
150
|
def inspect
|
123
|
-
return "#<%p:%#016x formatter: %s, level: %s, output: %s>" % [
|
151
|
+
return "#<%p:%#016x formatter: %s, level: %s, output: %s, affecting %s log hosts>" % [
|
124
152
|
self.class,
|
125
153
|
self.object_id * 2,
|
126
154
|
self.settings[:formatter] || '-',
|
127
155
|
self.settings[:level] || '-',
|
128
156
|
self.settings[:logdev] ? self.settings[:logdev].class : '-',
|
157
|
+
self.log_hosts ? self.log_hosts.length.to_s : "all",
|
129
158
|
]
|
130
159
|
end
|
131
160
|
|
@@ -137,7 +166,7 @@ class Loggability::Override
|
|
137
166
|
### Return a clone that has been modified with the specified +new_settings+.
|
138
167
|
def clone_with( new_settings, &block )
|
139
168
|
newobj = self.dup
|
140
|
-
newobj.
|
169
|
+
newobj.merge_settings( new_settings )
|
141
170
|
|
142
171
|
if block
|
143
172
|
return newobj.call( &block )
|
@@ -147,15 +176,30 @@ class Loggability::Override
|
|
147
176
|
end
|
148
177
|
|
149
178
|
|
179
|
+
### Merge any +new_settings+ into the receiving Override.
|
180
|
+
def merge_settings( new_settings )
|
181
|
+
if (( new_hosts = new_settings.delete(:log_hosts) ))
|
182
|
+
self.log_hosts = new_hosts
|
183
|
+
end
|
184
|
+
self.settings.merge!( new_settings )
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
### Return the log hosts that should be affected by the Override.
|
189
|
+
def log_hosts_to_affect
|
190
|
+
rval = Array( self.log_hosts || Loggability.log_hosts.values ).uniq
|
191
|
+
return rval.map {|obj| Loggability.log_host_for(obj) }
|
192
|
+
end
|
193
|
+
|
194
|
+
|
150
195
|
### Apply any configured overrides to all loggers.
|
151
196
|
def apply_overrides
|
152
197
|
self.synchronize do
|
153
|
-
raise LocalJumpError, "can't be called re-entrantly"
|
154
|
-
|
155
|
-
@overridden_settings = self.gather_current_settings
|
198
|
+
raise LocalJumpError, "can't be called re-entrantly" if self.overridden_settings
|
199
|
+
self.overridden_settings = self.gather_current_settings
|
156
200
|
end
|
157
201
|
|
158
|
-
|
202
|
+
self.log_hosts_to_affect.each do |host|
|
159
203
|
host.logger.restore_settings( self.settings )
|
160
204
|
end
|
161
205
|
end
|
@@ -163,7 +207,7 @@ class Loggability::Override
|
|
163
207
|
|
164
208
|
### Return a Hash of Loggers with the settings they currently have.
|
165
209
|
def gather_current_settings
|
166
|
-
return
|
210
|
+
return self.log_hosts_to_affect.each_with_object( {} ) do |host, hash|
|
167
211
|
hash[ host ] = host.logger.settings
|
168
212
|
end
|
169
213
|
end
|
@@ -172,10 +216,13 @@ class Loggability::Override
|
|
172
216
|
### Restore the last settings saved by #apply_overrides to their corresponding
|
173
217
|
### loggers.
|
174
218
|
def restore_overridden_settings
|
175
|
-
|
219
|
+
return unless self.overridden_settings
|
220
|
+
|
221
|
+
self.overridden_settings.each do |host, settings|
|
176
222
|
host.logger.restore_settings( settings )
|
177
223
|
end
|
178
|
-
|
224
|
+
|
225
|
+
self.overridden_settings = nil
|
179
226
|
end
|
180
227
|
|
181
228
|
end # class Loggability::Override
|
@@ -23,6 +23,12 @@ describe Loggability::Override do
|
|
23
23
|
log_as :testing
|
24
24
|
end
|
25
25
|
end
|
26
|
+
let!( :another_loghost ) do
|
27
|
+
Class.new do
|
28
|
+
extend Loggability
|
29
|
+
log_as :testing_another
|
30
|
+
end
|
31
|
+
end
|
26
32
|
|
27
33
|
|
28
34
|
it "doesn't override anything by default" do
|
@@ -85,6 +91,87 @@ describe Loggability::Override do
|
|
85
91
|
end
|
86
92
|
|
87
93
|
|
94
|
+
it "can mutate itself to only affect a subset of log hosts" do
|
95
|
+
log = []
|
96
|
+
|
97
|
+
Loggability.level = :info
|
98
|
+
Loggability.output_to( log )
|
99
|
+
Loggability.format_with( :default )
|
100
|
+
|
101
|
+
loghost_override = override.for_logger( another_loghost ).with_level( :debug )
|
102
|
+
|
103
|
+
another_loghost.logger.debug "This shouldn't show up."
|
104
|
+
loghost.logger.debug "This also shouldn't show up."
|
105
|
+
loghost_override.call do
|
106
|
+
loghost.logger.debug "And this also should not show up."
|
107
|
+
another_loghost.logger.debug "But this should."
|
108
|
+
end
|
109
|
+
loghost.logger.debug "This shouldn't show up either."
|
110
|
+
another_loghost.logger.debug "And neither should this."
|
111
|
+
|
112
|
+
expect( log.size ).to eq( 1 )
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
it "can affect a subset of more than one log host" do
|
117
|
+
log = []
|
118
|
+
|
119
|
+
Loggability.level = :info
|
120
|
+
Loggability.output_to( log )
|
121
|
+
Loggability.format_with( :default )
|
122
|
+
|
123
|
+
loghost_override = override.for_logger( loghost, another_loghost ).with_level( :debug )
|
124
|
+
|
125
|
+
another_loghost.logger.debug "This shouldn't show up."
|
126
|
+
loghost.logger.debug "This also shouldn't show up."
|
127
|
+
loghost_override.call do
|
128
|
+
loghost.logger.debug "Now this one should show up."
|
129
|
+
another_loghost.logger.debug "And so should this."
|
130
|
+
end
|
131
|
+
loghost.logger.debug "This shouldn't show up though."
|
132
|
+
another_loghost.logger.debug "And neither should this."
|
133
|
+
|
134
|
+
expect( log.size ).to eq( 2 )
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
it "works when mutating log hosts by log clients as well" do
|
139
|
+
log = []
|
140
|
+
|
141
|
+
Loggability.level = :info
|
142
|
+
Loggability.output_to( log )
|
143
|
+
Loggability.format_with( :default )
|
144
|
+
|
145
|
+
logclient = Class.new do
|
146
|
+
extend Loggability
|
147
|
+
log_to :testing
|
148
|
+
end
|
149
|
+
|
150
|
+
loghost_override = override.for_logger( logclient ).with_level( :debug )
|
151
|
+
|
152
|
+
another_loghost.logger.debug "This shouldn't show up."
|
153
|
+
loghost.logger.debug "This also shouldn't show up."
|
154
|
+
logclient.log.debug "And neither should this."
|
155
|
+
loghost_override.call do
|
156
|
+
another_loghost.logger.debug "And this also should not show up."
|
157
|
+
loghost.logger.debug "But this should since it's using the same logger as the client."
|
158
|
+
logclient.log.debug "And this one should too."
|
159
|
+
end
|
160
|
+
loghost.logger.debug "And now this shouldn't show up."
|
161
|
+
another_loghost.logger.debug "And neither should this."
|
162
|
+
logclient.log.debug "Nor this."
|
163
|
+
|
164
|
+
expect( log.size ).to eq( 2 )
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
it "errors if for_logger is called with no loggers" do
|
169
|
+
expect {
|
170
|
+
override.for_logger
|
171
|
+
}.to raise_error( ArgumentError, /no log hosts given/i )
|
172
|
+
end
|
173
|
+
|
174
|
+
|
88
175
|
it "has a constructor delegator for its output mutator" do
|
89
176
|
log = []
|
90
177
|
override = described_class.outputting_to( log )
|
@@ -130,6 +217,7 @@ describe Loggability::Override do
|
|
130
217
|
expect( override.settings[:level] ).to be( :debug )
|
131
218
|
end
|
132
219
|
|
220
|
+
|
133
221
|
it "executes a block passed to a mutator with the mutated override" do
|
134
222
|
Loggability.level = :info
|
135
223
|
Loggability.format_with( :default )
|
@@ -140,7 +228,6 @@ describe Loggability::Override do
|
|
140
228
|
:did_it
|
141
229
|
end
|
142
230
|
|
143
|
-
|
144
231
|
expect( result ).to eq( :did_it )
|
145
232
|
expect( log.size ).to eq( 1 )
|
146
233
|
expect( log.first ).to match( /Doing it!/ )
|
data/spec/loggability_spec.rb
CHANGED
@@ -145,26 +145,35 @@ describe Loggability do
|
|
145
145
|
|
146
146
|
before( :each ) do
|
147
147
|
Loggability.reset
|
148
|
-
|
148
|
+
end
|
149
|
+
|
150
|
+
let!( :loghost ) do
|
151
|
+
Class.new do
|
149
152
|
extend Loggability
|
150
153
|
log_as :testing
|
151
154
|
end
|
152
155
|
end
|
156
|
+
let!( :another_loghost ) do
|
157
|
+
Class.new do
|
158
|
+
extend Loggability
|
159
|
+
log_as :testing_another
|
160
|
+
end
|
161
|
+
end
|
153
162
|
|
154
163
|
|
155
164
|
it "can propagate a logging level to every loghost" do
|
156
165
|
Loggability.level = :warn
|
157
|
-
expect( Loggability[
|
166
|
+
expect( Loggability[loghost].level ).to be( :warn )
|
158
167
|
end
|
159
168
|
|
160
169
|
it "can propagate an outputter to every loghost" do
|
161
170
|
Loggability.output_to( $stdout )
|
162
|
-
expect( Loggability[
|
171
|
+
expect( Loggability[loghost].logdev.dev ).to be( $stdout )
|
163
172
|
end
|
164
173
|
|
165
174
|
it "can propagate a formatter to every loghost" do
|
166
175
|
Loggability.format_with( :color )
|
167
|
-
expect( Loggability[
|
176
|
+
expect( Loggability[loghost].formatter ).to be_a( Loggability::Formatter::Color )
|
168
177
|
end
|
169
178
|
|
170
179
|
|
@@ -180,11 +189,11 @@ describe Loggability do
|
|
180
189
|
it "can temporarily override where Loggability outputs to while executing a block" do
|
181
190
|
tmp_output = []
|
182
191
|
|
183
|
-
Loggability[
|
192
|
+
Loggability[ loghost ].info "Before the override"
|
184
193
|
Loggability.outputting_to( tmp_output ) do
|
185
|
-
Loggability[
|
194
|
+
Loggability[ loghost ].info "During the override"
|
186
195
|
end
|
187
|
-
Loggability[
|
196
|
+
Loggability[ loghost ].info "After the override"
|
188
197
|
|
189
198
|
expect( @default_output.size ).to eq( 2 )
|
190
199
|
expect( tmp_output.size ).to eq( 1 )
|
@@ -195,15 +204,15 @@ describe Loggability do
|
|
195
204
|
tmp_output = []
|
196
205
|
with_tmp_logging = Loggability.outputting_to( tmp_output )
|
197
206
|
|
198
|
-
Loggability[
|
207
|
+
Loggability[ loghost ].info "Before the overrides"
|
199
208
|
with_tmp_logging.call do
|
200
|
-
Loggability[
|
209
|
+
Loggability[ loghost ].info "During the first override"
|
201
210
|
end
|
202
|
-
Loggability[
|
211
|
+
Loggability[ loghost ].info "Between overrides"
|
203
212
|
with_tmp_logging.call do
|
204
|
-
Loggability[
|
213
|
+
Loggability[ loghost ].info "During the second override"
|
205
214
|
end
|
206
|
-
Loggability[
|
215
|
+
Loggability[ loghost ].info "After the overrides"
|
207
216
|
|
208
217
|
expect( @default_output.size ).to eq( 3 )
|
209
218
|
expect( tmp_output.size ).to eq( 2 )
|
@@ -211,11 +220,11 @@ describe Loggability do
|
|
211
220
|
|
212
221
|
|
213
222
|
it "can temporarily override what level Loggability logs at while executing a block" do
|
214
|
-
Loggability[
|
223
|
+
Loggability[ loghost ].debug "Before the override"
|
215
224
|
Loggability.with_level( :debug ) do
|
216
|
-
Loggability[
|
225
|
+
Loggability[ loghost ].debug "During the override"
|
217
226
|
end
|
218
|
-
Loggability[
|
227
|
+
Loggability[ loghost ].debug "After the override"
|
219
228
|
|
220
229
|
expect( @default_output.size ).to eq( 1 )
|
221
230
|
end
|
@@ -224,26 +233,26 @@ describe Loggability do
|
|
224
233
|
it "can return an object that overrides what level Loggability logs at for any block" do
|
225
234
|
with_debug_logging = Loggability.with_level( :debug )
|
226
235
|
|
227
|
-
Loggability[
|
236
|
+
Loggability[ loghost ].debug "Before the overrides"
|
228
237
|
with_debug_logging.call do
|
229
|
-
Loggability[
|
238
|
+
Loggability[ loghost ].debug "During the first override"
|
230
239
|
end
|
231
|
-
Loggability[
|
240
|
+
Loggability[ loghost ].debug "Between overrides"
|
232
241
|
with_debug_logging.call do
|
233
|
-
Loggability[
|
242
|
+
Loggability[ loghost ].debug "During the second override"
|
234
243
|
end
|
235
|
-
Loggability[
|
244
|
+
Loggability[ loghost ].debug "After the overrides"
|
236
245
|
|
237
246
|
expect( @default_output.size ).to eq( 2 )
|
238
247
|
end
|
239
248
|
|
240
249
|
|
241
250
|
it "can temporarily override what formatter loggers use while executing a block" do
|
242
|
-
Loggability[
|
251
|
+
Loggability[ loghost ].info "Before the override"
|
243
252
|
Loggability.formatted_with( :html ) do
|
244
|
-
Loggability[
|
253
|
+
Loggability[ loghost ].info "During the override"
|
245
254
|
end
|
246
|
-
Loggability[
|
255
|
+
Loggability[ loghost ].info "After the override"
|
247
256
|
|
248
257
|
expect( @default_output.size ).to eq( 3 )
|
249
258
|
expect( @default_output.grep(/<div/).size ).to eq( 1 )
|
@@ -253,21 +262,68 @@ describe Loggability do
|
|
253
262
|
it "can return an object that overrides what formatter loggers use for any block" do
|
254
263
|
with_html_logging = Loggability.formatted_with( :html )
|
255
264
|
|
256
|
-
Loggability[
|
265
|
+
Loggability[ loghost ].info "Before the overrides"
|
257
266
|
with_html_logging.call do
|
258
|
-
Loggability[
|
267
|
+
Loggability[ loghost ].info "During the first override"
|
259
268
|
end
|
260
|
-
Loggability[
|
269
|
+
Loggability[ loghost ].info "Between overrides"
|
261
270
|
with_html_logging.call do
|
262
|
-
Loggability[
|
271
|
+
Loggability[ loghost ].info "During the second override"
|
263
272
|
end
|
264
|
-
Loggability[
|
273
|
+
Loggability[ loghost ].info "After the overrides"
|
265
274
|
|
266
275
|
expect( @default_output.size ).to eq( 5 )
|
267
276
|
expect( @default_output.grep(/<div/).size ).to eq( 2 )
|
268
277
|
end
|
269
278
|
|
270
279
|
|
280
|
+
it "can temporarily override settings for only a subset of log hosts" do
|
281
|
+
for_only_one_loghost = Loggability.
|
282
|
+
for_logger( another_loghost ).
|
283
|
+
with_level( :debug )
|
284
|
+
|
285
|
+
Loggability[ loghost ].debug "Before the overrides"
|
286
|
+
Loggability[ another_loghost ].debug "Before the overrides"
|
287
|
+
for_only_one_loghost.call do
|
288
|
+
Loggability[ loghost ].debug "During the first override"
|
289
|
+
Loggability[ another_loghost ].debug "During the first override"
|
290
|
+
end
|
291
|
+
Loggability[ loghost ].debug "Between overrides"
|
292
|
+
Loggability[ another_loghost ].debug "Between overrides"
|
293
|
+
for_only_one_loghost.call do
|
294
|
+
Loggability[ loghost ].debug "During the second override"
|
295
|
+
Loggability[ another_loghost ].debug "During the second override"
|
296
|
+
end
|
297
|
+
Loggability[ loghost ].debug "After the overrides"
|
298
|
+
Loggability[ another_loghost ].debug "After the overrides"
|
299
|
+
|
300
|
+
expect( @default_output.size ).to eq( 2 )
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
it "can temporarily override settings for multiple log hosts" do
|
305
|
+
for_only_one_loghost = Loggability.
|
306
|
+
for_logger( loghost, another_loghost ).
|
307
|
+
with_level( :debug )
|
308
|
+
|
309
|
+
Loggability[ loghost ].debug "Before the overrides"
|
310
|
+
Loggability[ another_loghost ].debug "Before the overrides"
|
311
|
+
for_only_one_loghost.call do
|
312
|
+
Loggability[ loghost ].debug "During the first override"
|
313
|
+
Loggability[ another_loghost ].debug "During the first override"
|
314
|
+
end
|
315
|
+
Loggability[ loghost ].debug "Between overrides"
|
316
|
+
Loggability[ another_loghost ].debug "Between overrides"
|
317
|
+
for_only_one_loghost.call do
|
318
|
+
Loggability[ loghost ].debug "During the second override"
|
319
|
+
Loggability[ another_loghost ].debug "During the second override"
|
320
|
+
end
|
321
|
+
Loggability[ loghost ].debug "After the overrides"
|
322
|
+
Loggability[ another_loghost ].debug "After the overrides"
|
323
|
+
|
324
|
+
expect( @default_output.size ).to eq( 4 )
|
325
|
+
end
|
326
|
+
|
271
327
|
end
|
272
328
|
|
273
329
|
|
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.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -10,27 +10,32 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
|
14
|
+
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
15
|
+
HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+MQwwCgYDVQQDDANnZWQx
|
16
|
+
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
17
|
+
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC/JWGRHO+USzR97vXjkFgt
|
18
|
+
83qeNf2KHkcvrRTSnR64i6um/ziin0I0oX23H7VYrDJC9A/uoUa5nGRJS5Zw/+wW
|
19
|
+
ENcvWVZS4iUzi4dsYJGY6yEOsXh2CcF46+QevV8iE+UmbkU75V7Dy1JCaUOyizEt
|
20
|
+
TH5UHsOtUU7k9TYARt/TgYZKuaoAMZZd5qyVqhF1vV+7/Qzmp89NGflXf2xYP26a
|
21
|
+
4MAX2qqKX/FKXqmFO+AGsbwYTEds1mksBF3fGsFgsQWxftG8GfZQ9+Cyu2+l1eOw
|
22
|
+
cZ+lPcg834G9DrqW2zhqUoLr1MTly4pqxYGb7XoDhoR7dd1kFE2a067+DzWC/ADt
|
23
|
+
+QkcqWUm5oh1fN0eqr7NsZlVJDulFgdiiYPQiIN7UNsii4Wc9aZqBoGcYfBeQNPZ
|
24
|
+
soo/6za/bWajOKUmDhpqvaiRv9EDpVLzuj53uDoukMMwxCMfgb04+ckQ0t2G7wqc
|
25
|
+
/D+K9JW9DDs3Yjgv9k4h7YMhW5gftosd+NkNC/+Y2CkCAwEAAaN1MHMwCQYDVR0T
|
26
|
+
BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFHKN/nkRusdqCJEuq3lgB3fJvyTg
|
27
|
+
MBwGA1UdEQQVMBOBEWdlZEBGYWVyaWVNVUQub3JnMBwGA1UdEgQVMBOBEWdlZEBG
|
28
|
+
YWVyaWVNVUQub3JnMA0GCSqGSIb3DQEBCwUAA4IBgQAPJzKiT0zBU7kpqe0aS2qb
|
29
|
+
FI0PJ4y5I8buU4IZGUD5NEt/N7pZNfOyBxkrZkXhS44Fp+xwBH5ebLbq/WY78Bqd
|
30
|
+
db0z6ZgW4LMYMpWFfbXsRbd9TU2f52L8oMAhxOvF7Of5qJMVWuFQ8FPagk2iHrdH
|
31
|
+
inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
|
32
|
+
DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
|
33
|
+
PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
|
34
|
+
6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
|
35
|
+
w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
|
36
|
+
p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-
|
38
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: hoe-mercurial
|
@@ -136,14 +141,14 @@ dependencies:
|
|
136
141
|
requirements:
|
137
142
|
- - "~>"
|
138
143
|
- !ruby/object:Gem::Version
|
139
|
-
version: '3.
|
144
|
+
version: '3.15'
|
140
145
|
type: :development
|
141
146
|
prerelease: false
|
142
147
|
version_requirements: !ruby/object:Gem::Requirement
|
143
148
|
requirements:
|
144
149
|
- - "~>"
|
145
150
|
- !ruby/object:Gem::Version
|
146
|
-
version: '3.
|
151
|
+
version: '3.15'
|
147
152
|
description: "A composable logging system built on the standard Logger library.\n\nYou
|
148
153
|
can add Loggability to large libraries and systems, then hook everything\nup later
|
149
154
|
when you know where you want logs to be written, at what level of\nseverity, and
|
@@ -213,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
218
|
version: '0'
|
214
219
|
requirements: []
|
215
220
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.6.8
|
217
222
|
signing_key:
|
218
223
|
specification_version: 4
|
219
224
|
summary: A composable logging system built on the standard Logger library
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
(����6|%_��x��Iv�g������������(nf�g5N@Ф
|
2
|
+
��;D2�8M�p�C2]�o�`���{�<R9H-`���t�nJɨC�Ȧ
|
3
|
+
[l�"�WY��$��&I���G����3L�3����H��+s���0�S���h�1�j����@�[Hu��Iz�=�^o�ӻ��i��j|`�z��e����th��0'�?�<؋�)�i���}2|#���j�))�����s%���ī�JI<;J\PN�*����3B��^����)��UTB;�Cʢy�-�Ǽ�2g�3>A�B֧o���܄!��@���Y>����
|