loggability 0.11.0 → 0.12.0.pre20161212115530
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.simplecov +9 -0
- data/ChangeLog +153 -2
- data/History.rdoc +11 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -1
- data/Rakefile +13 -8
- data/lib/loggability.rb +64 -44
- data/lib/loggability/formatter.rb +7 -7
- data/lib/loggability/logclient.rb +8 -1
- data/lib/loggability/loghost.rb +0 -6
- data/spec/loggability/formatter_spec.rb +14 -3
- data/spec/loggability/override_spec.rb +1 -1
- data/spec/loggability_spec.rb +27 -8
- metadata +64 -59
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9111cb6dd131b8808684c31e06dab0dc769efead
|
4
|
+
data.tar.gz: eed7fd5ba5b4fb700e3e04f314c634115732ebb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4973262889355f718befcf2fea85442798f2cb4b97908a9feaaab522dc978664e45b1def2448aabe6212022675581e0f8c72a0d5a4f95ddf8fce759f1e44f1d
|
7
|
+
data.tar.gz: 92daec5ddaacf677ee1e6b7e8302d62804b15524417b1e167f8fcfe581b424c5a49d1a9381c6580e51b8a6754213ee6d6c3d60dea496dd08a9acc1b8ea182931
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/.simplecov
ADDED
data/ChangeLog
CHANGED
@@ -1,8 +1,159 @@
|
|
1
|
+
2015-03-01 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* Rakefile:
|
4
|
+
Set the title on generated docs
|
5
|
+
[433f9c68760f] [tip]
|
6
|
+
|
7
|
+
2015-02-27 Michael Granger <ged@FaerieMUD.org>
|
8
|
+
|
9
|
+
* .hgignore, loggability.gemspec:
|
10
|
+
Forgot to add the gemspec
|
11
|
+
[13282fe8202d] [github/master]
|
12
|
+
|
13
|
+
* .rvmrc, .simplecov, .travis.yml, Gemfile, Rakefile:
|
14
|
+
Prep for travis-ci builds
|
15
|
+
[7c42a3ce53e6]
|
16
|
+
|
17
|
+
* lib/loggability/formatter.rb, spec/loggability/formatter_spec.rb:
|
18
|
+
Use the current thread's object ID and not the Thread class's
|
19
|
+
[9d022ce39171]
|
20
|
+
|
21
|
+
2014-04-14 Michael Granger <ged@FaerieMUD.org>
|
22
|
+
|
23
|
+
* .hgtags:
|
24
|
+
Added tag v0.11.0 for changeset 430cb8049ae4
|
25
|
+
[c26d488a0129]
|
26
|
+
|
27
|
+
* .hgsigs:
|
28
|
+
Added signature for changeset fa08d10cb3b6
|
29
|
+
[430cb8049ae4] [v0.11.0]
|
30
|
+
|
31
|
+
2014-04-02 Michael Granger <ged@FaerieMUD.org>
|
32
|
+
|
33
|
+
* History.rdoc, lib/loggability.rb:
|
34
|
+
Bump the minor version, update history.
|
35
|
+
[fa08d10cb3b6]
|
36
|
+
|
37
|
+
* .hgignore, Rakefile, lib/loggability/logger.rb,
|
38
|
+
lib/loggability/loghost.rb, spec/helpers.rb,
|
39
|
+
spec/loggability/formatter/color_spec.rb,
|
40
|
+
spec/loggability/formatter/html_spec.rb,
|
41
|
+
spec/loggability/logger_spec.rb, spec/loggability/override_spec.rb:
|
42
|
+
Fix a bug when a log host is subclassed.
|
43
|
+
|
44
|
+
- Inheriting a log host now registers the subclass as its own log
|
45
|
+
host.
|
46
|
+
- Add a gemspec-building task.
|
47
|
+
- Eliminated the last vestiges of deprecated RSpec syntax.
|
48
|
+
[dc975db7ae50]
|
49
|
+
|
50
|
+
2014-03-24 Michael Granger <ged@FaerieMUD.org>
|
51
|
+
|
52
|
+
* .hgtags:
|
53
|
+
Added tag v0.10.1 for changeset ed0c5e115cac
|
54
|
+
[ec646cc6977a]
|
55
|
+
|
56
|
+
* .hgsigs:
|
57
|
+
Added signature for changeset 24fd8762623d
|
58
|
+
[ed0c5e115cac] [v0.10.1]
|
59
|
+
|
60
|
+
* History.rdoc, lib/loggability.rb:
|
61
|
+
Bump the patch version, update history.
|
62
|
+
[24fd8762623d]
|
63
|
+
|
64
|
+
* .rvm.gems, Gemfile, lib/loggability.rb, spec/loggability_spec.rb:
|
65
|
+
Raise an exception when something attempts to use a non-existant log
|
66
|
+
host.
|
67
|
+
[bbbb41b5f199]
|
68
|
+
|
69
|
+
2014-02-04 Michael Granger <ged@FaerieMUD.org>
|
70
|
+
|
71
|
+
* .hgtags:
|
72
|
+
Added tag v0.10.0 for changeset 75f1eb53eefa
|
73
|
+
[f87a413e30fd]
|
74
|
+
|
75
|
+
* .hgsigs:
|
76
|
+
Added signature for changeset b1250807b56e
|
77
|
+
[75f1eb53eefa] [v0.10.0]
|
78
|
+
|
79
|
+
* History.rdoc, lib/loggability.rb:
|
80
|
+
Bump the minor version, update history.
|
81
|
+
[b1250807b56e]
|
82
|
+
|
83
|
+
* lib/loggability/logger.rb, spec/loggability/logger_spec.rb:
|
84
|
+
Add a #write method to Loggability::Logger for Rack::CommonLogger
|
85
|
+
compatibility.
|
86
|
+
[b7911c961bb0]
|
87
|
+
|
88
|
+
2014-01-17 Michael Granger <ged@FaerieMUD.org>
|
89
|
+
|
90
|
+
* .hgtags:
|
91
|
+
Added tag v0.9.0 for changeset 6f90bce76e3b
|
92
|
+
[978864d0a0f0]
|
93
|
+
|
94
|
+
* .hgsigs:
|
95
|
+
Added signature for changeset 05e0a87c92c7
|
96
|
+
[6f90bce76e3b] [v0.9.0]
|
97
|
+
|
98
|
+
* Gemfile:
|
99
|
+
Update the Gemfile
|
100
|
+
[05e0a87c92c7]
|
101
|
+
|
102
|
+
2014-01-08 Michael Granger <ged@FaerieMUD.org>
|
103
|
+
|
104
|
+
* Rakefile:
|
105
|
+
Use newer hoe plugin
|
106
|
+
[5a465a2c0e79]
|
107
|
+
|
108
|
+
* .rvm.gems:
|
109
|
+
Update RVM gemset
|
110
|
+
[ec28321ba712]
|
111
|
+
|
112
|
+
* History.rdoc, lib/loggability.rb:
|
113
|
+
Bump the minor version, update history.
|
114
|
+
[469cf788e750]
|
115
|
+
|
116
|
+
* spec/loggability/logger_spec.rb, spec/loggability/override_spec.rb,
|
117
|
+
spec/loggability_spec.rb:
|
118
|
+
Fix deprecated RSpec stuff
|
119
|
+
[60116eaa175f]
|
120
|
+
|
121
|
+
2013-11-22 Michael Granger <ged@FaerieMUD.org>
|
122
|
+
|
123
|
+
* Manifest.txt, README.rdoc, Rakefile, lib/loggability/spechelpers.rb,
|
124
|
+
spec/helpers.rb, spec/loggability/spechelpers_spec.rb:
|
125
|
+
Make the spechelpers a little more intelligent.
|
126
|
+
|
127
|
+
- You no longer need to do setup_logging/reset_logging in a
|
128
|
+
before(:all)/after(:all) block; that's done for you.
|
129
|
+
- You can now override the logging level for any example group by
|
130
|
+
adding 'logging' or 'log' metadata.
|
131
|
+
- Fixed some documentation, added docs for the spec helpers.
|
132
|
+
[c888220ef581]
|
133
|
+
|
134
|
+
2013-10-09 Michael Granger <ged@FaerieMUD.org>
|
135
|
+
|
136
|
+
* .hgtags:
|
137
|
+
Added tag v0.8.1 for changeset 9bf0ab5413b3
|
138
|
+
[bfdae6012fa6]
|
139
|
+
|
140
|
+
* .hgsigs:
|
141
|
+
Added signature for changeset db603bf7b399
|
142
|
+
[9bf0ab5413b3] [v0.8.1]
|
143
|
+
|
144
|
+
* History.rdoc, lib/loggability.rb:
|
145
|
+
Bump the patch version, update history.
|
146
|
+
[db603bf7b399]
|
147
|
+
|
148
|
+
* lib/loggability/override.rb, spec/loggability/override_spec.rb:
|
149
|
+
Fix the problem with blocks not being called in chained overrides.
|
150
|
+
[a3d578201547]
|
151
|
+
|
1
152
|
2013-10-07 Michael Granger <ged@FaerieMUD.org>
|
2
153
|
|
3
154
|
* .hgtags:
|
4
155
|
Added tag v0.8.0 for changeset 9e8338f511bf
|
5
|
-
[d9e93e136b47]
|
156
|
+
[d9e93e136b47]
|
6
157
|
|
7
158
|
* .hgsigs:
|
8
159
|
Added signature for changeset a4c6b86b7cbc
|
@@ -16,7 +167,7 @@
|
|
16
167
|
|
17
168
|
* .hgignore, Gemfile.lock:
|
18
169
|
Remove generated file.
|
19
|
-
[377006201c40]
|
170
|
+
[377006201c40]
|
20
171
|
|
21
172
|
* loggability.gemspec:
|
22
173
|
Remove generated file.
|
data/History.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== v0.12.0 [2016-12-12] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
|
5
|
+
- Don't make classes that inherit loghosts their own loghosts
|
6
|
+
- Fix configuration so it's applied more consistently
|
7
|
+
- Post-configure log hosts created after config is loaded
|
8
|
+
- Clear the log proxy for duped/cloned log clients
|
9
|
+
- Use the current thread's object ID in the log message and not the Thread class's
|
10
|
+
|
11
|
+
|
1
12
|
== v0.11.0 [2014-04-02] Michael Granger <ged@FaerieMUD.org>
|
2
13
|
|
3
14
|
Fix a bug when a log host is subclassed.
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -13,7 +13,6 @@ GEMSPEC = 'loggability.gemspec'
|
|
13
13
|
Hoe.plugin :mercurial
|
14
14
|
Hoe.plugin :signing
|
15
15
|
Hoe.plugin :deveiate
|
16
|
-
Hoe.plugin :bundler
|
17
16
|
|
18
17
|
Hoe.plugins.delete :rubyforge
|
19
18
|
|
@@ -40,7 +39,7 @@ end
|
|
40
39
|
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
41
40
|
|
42
41
|
# Ensure the specs pass before checking in
|
43
|
-
task 'hg:precheckin' => [ :check_history,
|
42
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
|
44
43
|
|
45
44
|
|
46
45
|
desc "Build a coverage report"
|
@@ -48,6 +47,8 @@ task :coverage do
|
|
48
47
|
ENV["COVERAGE"] = 'yes'
|
49
48
|
Rake::Task[:spec].invoke
|
50
49
|
end
|
50
|
+
CLOBBER.include( 'coverage' )
|
51
|
+
|
51
52
|
|
52
53
|
# Use the fivefish formatter for docs generated from development checkout
|
53
54
|
if File.directory?( '.hg' )
|
@@ -58,19 +59,23 @@ if File.directory?( '.hg' )
|
|
58
59
|
rdoc.main = "README.rdoc"
|
59
60
|
rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
|
60
61
|
rdoc.generator = :fivefish
|
62
|
+
rdoc.title = 'Loggability'
|
61
63
|
rdoc.rdoc_dir = 'doc'
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
65
67
|
task :gemspec => GEMSPEC
|
66
|
-
file GEMSPEC => __FILE__
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
file GEMSPEC => [ __FILE__, 'lib/loggability.rb' ]
|
69
|
+
task GEMSPEC do |task|
|
70
|
+
hoespec = $hoespec.spec
|
71
|
+
hoespec.files.delete( '.gemtest' )
|
72
|
+
hoespec.signing_key = nil
|
73
|
+
hoespec.version = "#{hoespec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
|
74
|
+
hoespec.cert_chain = [ 'certs/ged.pem' ]
|
70
75
|
File.open( task.name, 'w' ) do |fh|
|
71
|
-
fh.write(
|
76
|
+
fh.write( hoespec.to_ruby )
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
75
|
-
|
80
|
+
CLOBBER.include( GEMSPEC.to_s )
|
76
81
|
|
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.12.0'
|
13
13
|
|
14
14
|
# VCS revision
|
15
|
-
REVISION = %q$Revision:
|
15
|
+
REVISION = %q$Revision: 6379f2040f92 $
|
16
16
|
|
17
17
|
# The key for the global logger (Loggability's own logger)
|
18
18
|
GLOBAL_KEY = :__global__
|
@@ -23,7 +23,7 @@ module Loggability
|
|
23
23
|
# Configuration defaults
|
24
24
|
CONFIG_DEFAULTS = {
|
25
25
|
:__default__ => 'warn STDERR',
|
26
|
-
}
|
26
|
+
}.freeze
|
27
27
|
|
28
28
|
# Regexp for parsing logspec lines in the config
|
29
29
|
LOGSPEC_PATTERN = %r{
|
@@ -52,6 +52,11 @@ module Loggability
|
|
52
52
|
class << self; attr_reader :log_hosts; end
|
53
53
|
@log_hosts = {}
|
54
54
|
|
55
|
+
##
|
56
|
+
# The last logging configuration that was installed
|
57
|
+
class << self; attr_accessor :config; end
|
58
|
+
@config = CONFIG_DEFAULTS.dup.freeze
|
59
|
+
|
55
60
|
|
56
61
|
# Automatically log the log host and log client mixins when they're referenced
|
57
62
|
autoload :LogHost, 'loggability/loghost'
|
@@ -81,12 +86,20 @@ module Loggability
|
|
81
86
|
def self::register_loghost( host )
|
82
87
|
key = host.log_host_key
|
83
88
|
if self.log_hosts.key?( key )
|
89
|
+
# raise "Can't set a log host for nil" if key.nil?
|
84
90
|
self.logger.warn "Replacing existing log host for %p (%p) with %p" %
|
85
91
|
[ key, self.log_hosts[key], host ]
|
86
92
|
end
|
87
93
|
|
88
|
-
self.logger.debug "Registering %p log host: %p" % [ key, host ] if self.logger
|
94
|
+
#self.logger.debug "Registering %p log host: %p" % [ key, host ] if self.logger
|
89
95
|
self.log_hosts[ key ] = host
|
96
|
+
if (( logspec = Loggability.config[key] ))
|
97
|
+
self.apply_config( host.logger, logspec )
|
98
|
+
elsif (( defaultspec = (Loggability.config[:__default__] || Loggability.config['__default__']) ))
|
99
|
+
self.apply_config( host.logger, defaultspec )
|
100
|
+
else
|
101
|
+
self.apply_config( host.logger, CONFIG_DEFAULTS[:__default__] )
|
102
|
+
end
|
90
103
|
end
|
91
104
|
|
92
105
|
|
@@ -118,10 +131,12 @@ module Loggability
|
|
118
131
|
end
|
119
132
|
|
120
133
|
|
121
|
-
### Clear out all log hosts
|
122
|
-
###
|
123
|
-
def self::
|
124
|
-
self.log_hosts.
|
134
|
+
### Clear out all registered log hosts and reset the default logger. This is
|
135
|
+
### mostly intended for facilitating tests.
|
136
|
+
def self::reset
|
137
|
+
self.log_hosts.clear
|
138
|
+
self.logger = self.default_logger = Loggability::Logger.new
|
139
|
+
Loggability.register_loghost( self )
|
125
140
|
end
|
126
141
|
|
127
142
|
|
@@ -263,6 +278,39 @@ module Loggability
|
|
263
278
|
end
|
264
279
|
|
265
280
|
|
281
|
+
|
282
|
+
#
|
283
|
+
# :section: Configurability Support
|
284
|
+
#
|
285
|
+
|
286
|
+
### Configure the specified +logger+ (or anything that ducktypes the same) with the
|
287
|
+
### configuration specified by +logspec+.
|
288
|
+
def self::apply_config( logger, logspec )
|
289
|
+
level, format, target = self.parse_config_spec( logspec )
|
290
|
+
logger.level = level if level
|
291
|
+
logger.format_with( format ) if format
|
292
|
+
logger.output_to( target ) if target
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
### Parse the specified +spec+ into level,
|
297
|
+
def self::parse_config_spec( spec )
|
298
|
+
match = LOGSPEC_PATTERN.match( spec ) or
|
299
|
+
raise ArgumentError, "Couldn't parse logspec: %p" % [ spec ]
|
300
|
+
# self.log.debug " parsed config spec %p -> %p" % [ spec, match ]
|
301
|
+
severity, target, format = match.captures
|
302
|
+
|
303
|
+
target = case target
|
304
|
+
when 'STDOUT' then $stdout
|
305
|
+
when 'STDERR' then $stderr
|
306
|
+
else
|
307
|
+
target
|
308
|
+
end
|
309
|
+
|
310
|
+
return severity, format, target
|
311
|
+
end
|
312
|
+
|
313
|
+
|
266
314
|
# Install a global logger in Loggability itself
|
267
315
|
extend( Loggability::LogHost )
|
268
316
|
self.log_host_key = GLOBAL_KEY
|
@@ -270,22 +318,15 @@ module Loggability
|
|
270
318
|
Loggability.register_loghost( self )
|
271
319
|
|
272
320
|
|
273
|
-
#
|
274
|
-
# :section: Configurability Support
|
275
|
-
#
|
276
|
-
|
277
321
|
### Configurability API -- configure logging.
|
278
|
-
def self::configure(
|
279
|
-
if
|
280
|
-
self.
|
281
|
-
confighash =
|
322
|
+
def self::configure( new_config=nil )
|
323
|
+
if new_config
|
324
|
+
self.config = new_config.dup.freeze
|
325
|
+
confighash = new_config.to_hash
|
282
326
|
|
283
327
|
# Set up all loggers with defaults first
|
284
328
|
if defaultspec = confighash.delete( :__default__ ) || confighash.delete( '__default__' )
|
285
|
-
|
286
|
-
Loggability.level = level if level
|
287
|
-
Loggability.format_as( format ) if format
|
288
|
-
Loggability.output_to( target ) if target
|
329
|
+
self.apply_config( self, defaultspec )
|
289
330
|
end
|
290
331
|
|
291
332
|
# Then let individual configs override.
|
@@ -295,35 +336,14 @@ module Loggability
|
|
295
336
|
next
|
296
337
|
end
|
297
338
|
|
298
|
-
self.log.debug " configuring logger for %p: %s" % [ key, logspec ]
|
299
|
-
|
300
|
-
Loggability[ key ].level = level if level
|
301
|
-
Loggability[ key ].format_with( format ) if format
|
302
|
-
Loggability[ key ].output_to( target ) if target
|
339
|
+
# self.log.debug " configuring logger for %p: %s" % [ key, logspec ]
|
340
|
+
self.apply_config( Loggability[key], logspec )
|
303
341
|
end
|
304
342
|
else
|
305
|
-
self.
|
343
|
+
self.config = self.defaults.dup.freeze
|
306
344
|
end
|
307
345
|
end
|
308
346
|
|
309
347
|
|
310
|
-
### Parse the specified +spec+ into level,
|
311
|
-
def self::parse_config_spec( spec )
|
312
|
-
match = LOGSPEC_PATTERN.match( spec ) or
|
313
|
-
raise ArgumentError, "Couldn't parse logspec: %p" % [ spec ]
|
314
|
-
self.log.debug " parsed config spec %p -> %p" % [ spec, match ]
|
315
|
-
severity, target, format = match.captures
|
316
|
-
|
317
|
-
target = case target
|
318
|
-
when 'STDOUT' then $stdout
|
319
|
-
when 'STDERR' then $stderr
|
320
|
-
else
|
321
|
-
target
|
322
|
-
end
|
323
|
-
|
324
|
-
return severity, format, target
|
325
|
-
end
|
326
|
-
|
327
|
-
|
328
348
|
end # module Loggability
|
329
349
|
|
@@ -76,13 +76,13 @@ class Loggability::Formatter
|
|
76
76
|
def call( severity, time, progname, message )
|
77
77
|
timeformat = self.datetime_format
|
78
78
|
args = [
|
79
|
-
time.strftime( timeformat ),
|
80
|
-
time.usec,
|
81
|
-
Process.pid,
|
82
|
-
Thread.current == Thread.main ? 'main' : Thread.object_id,
|
83
|
-
severity.downcase,
|
84
|
-
progname,
|
85
|
-
self.msg2str(message, severity)
|
79
|
+
time.strftime( timeformat ), # %1$s
|
80
|
+
time.usec, # %2$d
|
81
|
+
Process.pid, # %3$d
|
82
|
+
Thread.current == Thread.main ? 'main' : Thread.current.object_id, # %4$s
|
83
|
+
severity.downcase, # %5$s
|
84
|
+
progname, # %6$s
|
85
|
+
self.msg2str(message, severity) # %7$s
|
86
86
|
]
|
87
87
|
|
88
88
|
return self.format % args
|
@@ -28,9 +28,16 @@ module Loggability::LogClient
|
|
28
28
|
end
|
29
29
|
|
30
30
|
|
31
|
-
# Stuff that gets added to instances of Classes that are log
|
31
|
+
# Stuff that gets added to instances of Classes that are log clients.
|
32
32
|
module InstanceMethods
|
33
33
|
|
34
|
+
### Unset the logger proxy for copies of the logged object.
|
35
|
+
def initialize_copy( other )
|
36
|
+
super
|
37
|
+
@__log = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
|
34
41
|
### Fetch the key of the log host the instance of this client targets
|
35
42
|
def log_host_key
|
36
43
|
return self.class.log_host_key
|
data/lib/loggability/loghost.rb
CHANGED
@@ -36,12 +36,6 @@ module Loggability::LogHost
|
|
36
36
|
alias_method :log=, :logger=
|
37
37
|
|
38
38
|
|
39
|
-
### Register subclasses of log hosts as their own log hosts.
|
40
|
-
def inherited( subclass )
|
41
|
-
super
|
42
|
-
Loggability.register_loghost( subclass )
|
43
|
-
end
|
44
|
-
|
45
39
|
end # module Loggability::LogHost
|
46
40
|
|
47
41
|
|
@@ -13,13 +13,14 @@ require 'loggability/formatter/default'
|
|
13
13
|
describe Loggability::Formatter do
|
14
14
|
|
15
15
|
it "formats messages with the pattern it's constructed with" do
|
16
|
-
formatter =
|
16
|
+
formatter = described_class.new( '[%5$s] %7$s' )
|
17
17
|
result = formatter.call( 'INFO', Time.at(1336286481), nil, 'Foom.' )
|
18
18
|
expect( result ).to match(/\[INFO\] Foom./i)
|
19
19
|
end
|
20
20
|
|
21
|
+
|
21
22
|
it "formats exceptions into useful messages" do
|
22
|
-
formatter =
|
23
|
+
formatter = described_class.new( '[%5$s] %7$s' )
|
23
24
|
msg = nil
|
24
25
|
|
25
26
|
begin
|
@@ -31,12 +32,22 @@ describe Loggability::Formatter do
|
|
31
32
|
expect( msg ).to match(/\[INFO\] ArgumentError: invalid argument/i)
|
32
33
|
end
|
33
34
|
|
35
|
+
|
34
36
|
it "formats regular objects into useful messages" do
|
35
|
-
formatter =
|
37
|
+
formatter = described_class.new( '[%5$s] %7$s' )
|
36
38
|
result = formatter.call( 'INFO', Time.at(1336286481), nil, Object.new )
|
37
39
|
|
38
40
|
expect( result ).to match(/\[INFO\] #<Object:0x[[:xdigit:]]+>/i)
|
39
41
|
end
|
40
42
|
|
43
|
+
|
44
|
+
it "includes the thread ID if logging from a thread other than the main thread" do
|
45
|
+
formatter = described_class.new( '%4$d' )
|
46
|
+
thr = Thread.new do
|
47
|
+
formatter.call( 'INFO', Time.now, nil, 'Foom.' )
|
48
|
+
end
|
49
|
+
expect( thr.value ).to eq( thr.object_id.to_s )
|
50
|
+
end
|
51
|
+
|
41
52
|
end
|
42
53
|
|
data/spec/loggability_spec.rb
CHANGED
@@ -10,11 +10,8 @@ require 'loggability/logger'
|
|
10
10
|
describe Loggability do
|
11
11
|
|
12
12
|
before( :each ) do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
after( :each ) do
|
17
|
-
reset_logging()
|
13
|
+
Loggability.reset
|
14
|
+
Loggability.configure
|
18
15
|
end
|
19
16
|
|
20
17
|
|
@@ -46,7 +43,7 @@ describe Loggability do
|
|
46
43
|
end
|
47
44
|
|
48
45
|
after( :each ) do
|
49
|
-
Loggability.
|
46
|
+
Loggability.reset
|
50
47
|
end
|
51
48
|
|
52
49
|
|
@@ -101,7 +98,7 @@ describe Loggability do
|
|
101
98
|
end
|
102
99
|
|
103
100
|
after( :each ) do
|
104
|
-
Loggability.
|
101
|
+
Loggability.reset
|
105
102
|
end
|
106
103
|
|
107
104
|
|
@@ -119,6 +116,12 @@ describe Loggability do
|
|
119
116
|
end
|
120
117
|
|
121
118
|
|
119
|
+
it "creates a new log proxy when duped" do
|
120
|
+
obj = @class.new
|
121
|
+
expect( obj.log ).to_not be( obj.dup.log )
|
122
|
+
end
|
123
|
+
|
124
|
+
|
122
125
|
it "is associated with its log host's logger via its instances through the Loggability module" do
|
123
126
|
obj = @class.new
|
124
127
|
expect( Loggability[obj] ).to be( @loghost.logger )
|
@@ -141,7 +144,7 @@ describe Loggability do
|
|
141
144
|
context "aggregate methods" do
|
142
145
|
|
143
146
|
before( :each ) do
|
144
|
-
Loggability.
|
147
|
+
Loggability.reset
|
145
148
|
@loghost = Class.new do
|
146
149
|
extend Loggability
|
147
150
|
log_as :testing
|
@@ -374,6 +377,22 @@ describe Loggability do
|
|
374
377
|
}.to raise_error( LoadError, /cannot load such file/i )
|
375
378
|
end
|
376
379
|
|
380
|
+
it "applies the last-loaded configuration to loggers when they are registered" do
|
381
|
+
Loggability.configure( __default__: 'warn', late_class: 'debug (color)' )
|
382
|
+
late_class = Class.new { extend Loggability; log_as :late_class }
|
383
|
+
|
384
|
+
expect( late_class.logger.level ).to eq( :debug )
|
385
|
+
expect( late_class.logger.formatter ).to be_a( Loggability::Formatter::Color )
|
386
|
+
end
|
387
|
+
|
388
|
+
it "applies the config defaults to loggers when they are registered" do
|
389
|
+
Loggability.configure( __default__: 'error' )
|
390
|
+
late_class = Class.new { def name; "TheTestClass"; end; extend Loggability; log_as :late_class }
|
391
|
+
|
392
|
+
expect( late_class.logger.level ).to eq( :error )
|
393
|
+
expect( late_class.logger.formatter ).to be_a( Loggability::Formatter::Default )
|
394
|
+
end
|
395
|
+
|
377
396
|
end
|
378
397
|
|
379
398
|
end
|
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.12.0.pre20161212115530
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -10,140 +10,145 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFADA+MQwwCgYDVQQDDANnZWQx
|
14
14
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
15
|
-
|
15
|
+
HhcNMTYwODIwMTgxNzQyWhcNMTcwODIwMTgxNzQyWjA+MQwwCgYDVQQDDANnZWQx
|
16
16
|
GTAXBgoJkiaJk/IsZAEZFglGYWVyaWVNVUQxEzARBgoJkiaJk/IsZAEZFgNvcmcw
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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:
|
38
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
41
|
name: hoe-mercurial
|
37
42
|
requirement: !ruby/object:Gem::Requirement
|
38
43
|
requirements:
|
39
|
-
- - ~>
|
44
|
+
- - "~>"
|
40
45
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.4
|
46
|
+
version: '1.4'
|
42
47
|
type: :development
|
43
48
|
prerelease: false
|
44
49
|
version_requirements: !ruby/object:Gem::Requirement
|
45
50
|
requirements:
|
46
|
-
- - ~>
|
51
|
+
- - "~>"
|
47
52
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.4
|
53
|
+
version: '1.4'
|
49
54
|
- !ruby/object:Gem::Dependency
|
50
55
|
name: hoe-deveiate
|
51
56
|
requirement: !ruby/object:Gem::Requirement
|
52
57
|
requirements:
|
53
|
-
- - ~>
|
58
|
+
- - "~>"
|
54
59
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0.
|
60
|
+
version: '0.8'
|
56
61
|
type: :development
|
57
62
|
prerelease: false
|
58
63
|
version_requirements: !ruby/object:Gem::Requirement
|
59
64
|
requirements:
|
60
|
-
- - ~>
|
65
|
+
- - "~>"
|
61
66
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0.
|
67
|
+
version: '0.8'
|
63
68
|
- !ruby/object:Gem::Dependency
|
64
69
|
name: hoe-highline
|
65
70
|
requirement: !ruby/object:Gem::Requirement
|
66
71
|
requirements:
|
67
|
-
- - ~>
|
72
|
+
- - "~>"
|
68
73
|
- !ruby/object:Gem::Version
|
69
74
|
version: '0.2'
|
70
75
|
type: :development
|
71
76
|
prerelease: false
|
72
77
|
version_requirements: !ruby/object:Gem::Requirement
|
73
78
|
requirements:
|
74
|
-
- - ~>
|
79
|
+
- - "~>"
|
75
80
|
- !ruby/object:Gem::Version
|
76
81
|
version: '0.2'
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
name: rdoc
|
79
|
-
requirement: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ~>
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '4.0'
|
84
|
-
type: :development
|
85
|
-
prerelease: false
|
86
|
-
version_requirements: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: '4.0'
|
91
82
|
- !ruby/object:Gem::Dependency
|
92
83
|
name: hoe-bundler
|
93
84
|
requirement: !ruby/object:Gem::Requirement
|
94
85
|
requirements:
|
95
|
-
- - ~>
|
86
|
+
- - "~>"
|
96
87
|
- !ruby/object:Gem::Version
|
97
88
|
version: '1.2'
|
98
89
|
type: :development
|
99
90
|
prerelease: false
|
100
91
|
version_requirements: !ruby/object:Gem::Requirement
|
101
92
|
requirements:
|
102
|
-
- - ~>
|
93
|
+
- - "~>"
|
103
94
|
- !ruby/object:Gem::Version
|
104
95
|
version: '1.2'
|
105
96
|
- !ruby/object:Gem::Dependency
|
106
97
|
name: simplecov
|
107
98
|
requirement: !ruby/object:Gem::Requirement
|
108
99
|
requirements:
|
109
|
-
- - ~>
|
100
|
+
- - "~>"
|
110
101
|
- !ruby/object:Gem::Version
|
111
102
|
version: '0.7'
|
112
103
|
type: :development
|
113
104
|
prerelease: false
|
114
105
|
version_requirements: !ruby/object:Gem::Requirement
|
115
106
|
requirements:
|
116
|
-
- - ~>
|
107
|
+
- - "~>"
|
117
108
|
- !ruby/object:Gem::Version
|
118
109
|
version: '0.7'
|
119
110
|
- !ruby/object:Gem::Dependency
|
120
111
|
name: configurability
|
121
112
|
requirement: !ruby/object:Gem::Requirement
|
122
113
|
requirements:
|
123
|
-
- - ~>
|
114
|
+
- - "~>"
|
124
115
|
- !ruby/object:Gem::Version
|
125
116
|
version: '2.0'
|
126
117
|
type: :development
|
127
118
|
prerelease: false
|
128
119
|
version_requirements: !ruby/object:Gem::Requirement
|
129
120
|
requirements:
|
130
|
-
- - ~>
|
121
|
+
- - "~>"
|
131
122
|
- !ruby/object:Gem::Version
|
132
123
|
version: '2.0'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: rdoc
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '4.0'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '4.0'
|
133
138
|
- !ruby/object:Gem::Dependency
|
134
139
|
name: hoe
|
135
140
|
requirement: !ruby/object:Gem::Requirement
|
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
|
@@ -165,7 +170,7 @@ extra_rdoc_files:
|
|
165
170
|
- Manifest.txt
|
166
171
|
- README.rdoc
|
167
172
|
files:
|
168
|
-
- .
|
173
|
+
- ".simplecov"
|
169
174
|
- ChangeLog
|
170
175
|
- History.rdoc
|
171
176
|
- Manifest.txt
|
@@ -196,23 +201,23 @@ licenses:
|
|
196
201
|
metadata: {}
|
197
202
|
post_install_message:
|
198
203
|
rdoc_options:
|
199
|
-
- --main
|
204
|
+
- "--main"
|
200
205
|
- README.rdoc
|
201
206
|
require_paths:
|
202
207
|
- lib
|
203
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
204
209
|
requirements:
|
205
|
-
- -
|
210
|
+
- - ">="
|
206
211
|
- !ruby/object:Gem::Version
|
207
212
|
version: 1.9.3
|
208
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
214
|
requirements:
|
210
|
-
- -
|
215
|
+
- - ">"
|
211
216
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
217
|
+
version: 1.3.1
|
213
218
|
requirements: []
|
214
219
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.6.7
|
216
221
|
signing_key:
|
217
222
|
specification_version: 4
|
218
223
|
summary: A composable logging system built on the standard Logger library
|
metadata.gz.sig
CHANGED
Binary file
|
data/.gemtest
DELETED
File without changes
|