lumber 0.13.0 → 0.13.1
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.
- data/CHANGELOG +5 -0
- data/generators/lumber/templates/log4r.yml +3 -1
- data/lib/lumber/lumber.rb +7 -0
- data/lib/lumber/version.rb +1 -1
- data/spec/lumber_spec.rb +23 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/lumber/lumber.rb
CHANGED
@@ -119,6 +119,13 @@ module Lumber
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
+
# Helper to make it easier to log context through log4r.yml
|
123
|
+
def format_mdc()
|
124
|
+
ctx = Log4r::MDC.get_context.collect {|k, v| k.to_s + "=" + v.to_s }.join(" ")
|
125
|
+
ctx.gsub!('%', '%%')
|
126
|
+
return ctx
|
127
|
+
end
|
128
|
+
|
122
129
|
private
|
123
130
|
|
124
131
|
# Adds a inheritance handler to Object so we can know to add loggers
|
data/lib/lumber/version.rb
CHANGED
data/spec/lumber_spec.rb
CHANGED
@@ -154,4 +154,27 @@ describe Lumber do
|
|
154
154
|
assert_valid_logger('Foo3', "root::Foo1::Foo3")
|
155
155
|
end
|
156
156
|
|
157
|
+
context "formatted MDC context" do
|
158
|
+
|
159
|
+
before(:each) do
|
160
|
+
Log4r::MDC.get_context.keys.each {|k| Log4r::MDC.remove(k) }
|
161
|
+
end
|
162
|
+
|
163
|
+
it "is empty for no context" do
|
164
|
+
Lumber.format_mdc.should == ""
|
165
|
+
end
|
166
|
+
|
167
|
+
it "has context vars" do
|
168
|
+
Log4r::MDC.put("foo", "bar")
|
169
|
+
Log4r::MDC.put("baz", "boo")
|
170
|
+
Lumber.format_mdc.should == "foo=bar baz=boo"
|
171
|
+
end
|
172
|
+
|
173
|
+
it "escapes %" do
|
174
|
+
Log4r::MDC.put("%foo", "%bar")
|
175
|
+
Lumber.format_mdc.should == "%%foo=%%bar"
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
157
180
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -235,7 +235,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
segments:
|
237
237
|
- 0
|
238
|
-
hash:
|
238
|
+
hash: 820786214147561006
|
239
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
240
240
|
none: false
|
241
241
|
requirements:
|
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
244
|
version: '0'
|
245
245
|
segments:
|
246
246
|
- 0
|
247
|
-
hash:
|
247
|
+
hash: 820786214147561006
|
248
248
|
requirements: []
|
249
249
|
rubyforge_project:
|
250
250
|
rubygems_version: 1.8.24
|