TwP-logging 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/logging.rb +12 -1
- data/lib/logging/appenders.rb +12 -1
- data/lib/logging/repository.rb +22 -0
- data/test/setup.rb +1 -30
- metadata +2 -2
data/History.txt
CHANGED
data/lib/logging.rb
CHANGED
@@ -22,7 +22,7 @@ module Logging
|
|
22
22
|
extend LittlePlugger
|
23
23
|
|
24
24
|
# :stopdoc:
|
25
|
-
VERSION = '1.2.
|
25
|
+
VERSION = '1.2.2'
|
26
26
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
27
27
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
28
28
|
LEVELS = {}
|
@@ -461,6 +461,17 @@ module Logging
|
|
461
461
|
log_internal {'shutdown called - closing all appenders'}
|
462
462
|
::Logging::Appenders.each {|appender| appender.close}
|
463
463
|
end
|
464
|
+
|
465
|
+
# Reset the logging framework to it's uninitialized state
|
466
|
+
def reset
|
467
|
+
::Logging::Repository.reset
|
468
|
+
::Logging::Appenders.reset
|
469
|
+
LEVELS.clear
|
470
|
+
LNAMES.clear
|
471
|
+
remove_instance_variable :@backtrace if defined? @backtrace
|
472
|
+
remove_const :MAX_LEVEL_LENGTH if const_defined? :MAX_LEVEL_LENGTH
|
473
|
+
remove_const :OBJ_FORMAT if const_defined? :OBJ_FORMAT
|
474
|
+
end
|
464
475
|
# :startdoc:
|
465
476
|
end
|
466
477
|
end # module Logging
|
data/lib/logging/appenders.rb
CHANGED
@@ -102,9 +102,20 @@ module Logging
|
|
102
102
|
#
|
103
103
|
def each( &block )
|
104
104
|
@appenders.values.each(&block)
|
105
|
-
nil
|
105
|
+
return nil
|
106
106
|
end
|
107
107
|
|
108
|
+
# :stopdoc:
|
109
|
+
def reset
|
110
|
+
@appenders.values.each {|appender|
|
111
|
+
next if appender.nil?
|
112
|
+
appender.close
|
113
|
+
}
|
114
|
+
@appenders.clear
|
115
|
+
return nil
|
116
|
+
end
|
117
|
+
# :startdoc:
|
118
|
+
|
108
119
|
extend self
|
109
120
|
@appenders = Hash.new
|
110
121
|
|
data/lib/logging/repository.rb
CHANGED
@@ -204,6 +204,28 @@ module Logging
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
+
# :stopdoc:
|
208
|
+
def self.reset
|
209
|
+
if defined?(@singleton__instance__)
|
210
|
+
@singleton__mutex__.synchronize {
|
211
|
+
@singleton__instance__ = nil
|
212
|
+
}
|
213
|
+
else
|
214
|
+
@__instance__ = nil
|
215
|
+
class << self
|
216
|
+
nonce = class << Singleton; self; end
|
217
|
+
if defined?(nonce::FirstInstanceCall)
|
218
|
+
define_method(:instance, nonce::FirstInstanceCall)
|
219
|
+
else
|
220
|
+
remove_method(:instance)
|
221
|
+
Singleton.__init__(::Logging::Repository)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
return nil
|
226
|
+
end
|
227
|
+
# :startdoc:
|
228
|
+
|
207
229
|
end # class Repository
|
208
230
|
end # module Logging
|
209
231
|
|
data/test/setup.rb
CHANGED
@@ -26,42 +26,13 @@ module LoggingTestCase
|
|
26
26
|
|
27
27
|
def setup
|
28
28
|
super
|
29
|
-
|
29
|
+
Logging.reset
|
30
30
|
FileUtils.rm_rf TMP
|
31
31
|
FileUtils.mkdir TMP
|
32
|
-
|
33
|
-
::Logging.module_eval do
|
34
|
-
::Logging::LEVELS.clear
|
35
|
-
::Logging::LNAMES.clear
|
36
|
-
remove_const :MAX_LEVEL_LENGTH if const_defined? :MAX_LEVEL_LENGTH
|
37
|
-
remove_const :OBJ_FORMAT if const_defined? :OBJ_FORMAT
|
38
|
-
end
|
39
|
-
|
40
|
-
::Logging::Repository.class_eval do
|
41
|
-
if defined?(@singleton__instance__)
|
42
|
-
@singleton__instance__ = nil
|
43
|
-
else
|
44
|
-
@__instance__ = nil
|
45
|
-
class << self
|
46
|
-
nonce = class << Singleton; self; end
|
47
|
-
if defined?(nonce::FirstInstanceCall)
|
48
|
-
define_method(:instance, nonce::FirstInstanceCall)
|
49
|
-
else
|
50
|
-
remove_method(:instance)
|
51
|
-
Singleton.__init__(::Logging::Repository)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
32
|
end
|
57
33
|
|
58
34
|
def teardown
|
59
35
|
super
|
60
|
-
::Logging.backtrace
|
61
|
-
::Logging.__send__(:remove_instance_variable, :@backtrace)
|
62
|
-
h = ::Logging::Appenders.instance_variable_get(:@appenders)
|
63
|
-
h.each_value {|a| a.close(false) unless a.nil? || a.closed?}
|
64
|
-
h.clear
|
65
36
|
FileUtils.rm_rf TMP
|
66
37
|
end
|
67
38
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: TwP-logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|