log4r 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -3
- data/Rakefile +2 -2
- data/TODO +3 -0
- data/src/log4r.rb +2 -2
- data/src/log4r/GDC.rb +1 -1
- data/src/log4r/MDC.rb +1 -1
- data/src/log4r/NDC.rb +1 -2
- data/src/log4r/formatter/patternformatter.rb +13 -8
- data/tests/testpatternformatter.rb +59 -2
- metadata +2 -2
data/README
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Log4r - A flexible logging library for Ruby
|
2
2
|
|
3
3
|
|
4
|
-
This release: 1.1.
|
5
|
-
Release date:
|
4
|
+
This release: 1.1.4
|
5
|
+
Release date: 12/Jan/2010
|
6
6
|
License: Ruby's
|
7
7
|
Maintainer: Colby Gutierrez-Kraybill
|
8
8
|
Contributors: Leon Torres Original Maintainer
|
@@ -88,4 +88,4 @@ code yourself. It's well documented and written in Ruby. :)
|
|
88
88
|
Also, try out the bug/request tracking system at
|
89
89
|
http://rubyforge.org/tracker/?group_id=203
|
90
90
|
|
91
|
-
Version: $Id: README,v 1.
|
91
|
+
Version: $Id: README,v 1.7 2010/01/12 09:34:06 colbygk Exp $
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
# $Id: Rakefile,v 1.
|
2
|
+
# $Id: Rakefile,v 1.7 2010/01/12 09:34:04 colbygk Exp $
|
3
3
|
|
4
4
|
# incorporated from Revolution Health version of log4r
|
5
5
|
|
@@ -10,7 +10,7 @@ require 'date'
|
|
10
10
|
require 'fileutils'
|
11
11
|
|
12
12
|
GEM = "log4r"
|
13
|
-
GEM_VERSION = "1.1.
|
13
|
+
GEM_VERSION = "1.1.4"
|
14
14
|
AUTHOR = "Colby Gutierrez-Kraybill"
|
15
15
|
EMAIL = "colby@astro.berkeley.edu"
|
16
16
|
HOMEPAGE = %q{http://log4r.rubyforge.org}
|
data/TODO
CHANGED
data/src/log4r.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# == Other Info
|
4
4
|
#
|
5
5
|
# Author:: Leon Torres
|
6
|
-
# Version:: $Id: log4r.rb,v 1.
|
6
|
+
# Version:: $Id: log4r.rb,v 1.7 2010/01/12 09:35:04 colbygk Exp $
|
7
7
|
|
8
8
|
require "log4r/outputter/fileoutputter"
|
9
9
|
require "log4r/outputter/consoleoutputters"
|
@@ -16,5 +16,5 @@ require "log4r/NDC"
|
|
16
16
|
require "log4r/MDC"
|
17
17
|
|
18
18
|
module Log4r
|
19
|
-
Log4rVersion = [1, 1,
|
19
|
+
Log4rVersion = [1, 1, 4].join '.'
|
20
20
|
end
|
data/src/log4r/GDC.rb
CHANGED
data/src/log4r/MDC.rb
CHANGED
data/src/log4r/NDC.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# == Other Info
|
4
4
|
#
|
5
|
-
# Version:: $Id: NDC.rb,v 1.
|
5
|
+
# Version:: $Id: NDC.rb,v 1.3 2010/01/12 09:28:48 colbygk Exp $
|
6
6
|
# Author:: Colby Gutierrez-Kraybill <colby(at)astro.berkeley.edu>
|
7
7
|
|
8
8
|
module Log4r
|
@@ -18,7 +18,6 @@ module Log4r
|
|
18
18
|
if ( Thread.current[NDCNAME] == nil ):
|
19
19
|
Thread.current[NDCNAME] = Array.new
|
20
20
|
Thread.current[NDCNAMEMAXDEPTH] = NDCDEFAULTMAXDEPTH
|
21
|
-
Thread.current[NDCNAME]
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# == Other Info
|
4
4
|
#
|
5
|
-
# Version:: $Id: patternformatter.rb,v 1.
|
5
|
+
# Version:: $Id: patternformatter.rb,v 1.8 2010/01/12 09:28:49 colbygk Exp $
|
6
6
|
|
7
7
|
require "log4r/formatter/formatter"
|
8
8
|
require "log4r/GDC"
|
@@ -31,15 +31,15 @@ module Log4r
|
|
31
31
|
"c" => 'event.name',
|
32
32
|
"C" => 'event.fullname',
|
33
33
|
"d" => 'format_date',
|
34
|
-
"g" => 'GDC.get()',
|
34
|
+
"g" => 'Log4r::GDC.get()',
|
35
35
|
"t" => '(event.tracer.nil? ? "no trace" : event.tracer[0])',
|
36
36
|
"m" => 'event.data',
|
37
37
|
"h" => '(Thread.current[:name] or Thread.current.to_s)',
|
38
38
|
"p" => 'Process.pid.to_s',
|
39
39
|
"M" => 'format_object(event.data)',
|
40
40
|
"l" => 'LNAMES[event.level]',
|
41
|
-
"x" => 'NDC.get()',
|
42
|
-
"X" => '
|
41
|
+
"x" => 'Log4r::NDC.get()',
|
42
|
+
"X" => 'Log4r::MDC.get("DTR_REPLACE")',
|
43
43
|
"%" => '"%"'
|
44
44
|
}
|
45
45
|
|
@@ -52,7 +52,7 @@ module Log4r
|
|
52
52
|
# * $5 is the directive letter
|
53
53
|
# * $6 is the stuff after the directive or "" if not applicable
|
54
54
|
|
55
|
-
DirectiveRegexp = /([^%]*)((%-?\d*(\.\d+)?)([
|
55
|
+
DirectiveRegexp = /([^%]*)((%-?\d*(\.\d+)?)([cCdgtmhpMlxX%]))?(\{.+?\})?(.*)/
|
56
56
|
|
57
57
|
# default date format
|
58
58
|
ISO8601 = "%Y-%m-%d %H:%M:%S"
|
@@ -116,9 +116,14 @@ module Log4r
|
|
116
116
|
# deal with the directive by inserting a %#.#s where %#.# is copied
|
117
117
|
# directy from the match
|
118
118
|
ebuff << match[3] + "s"
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
if ( match[5] == 'X' && match[6] != nil ) then
|
120
|
+
args <<
|
121
|
+
DirectiveTable[match[5]].gsub("DTR_REPLACE", match[6]).gsub(/[\{\}]/,'')
|
122
|
+
else
|
123
|
+
args << DirectiveTable[match[5]] # cull the data for our argument list
|
124
|
+
end
|
125
|
+
break if match[7].empty?
|
126
|
+
_pattern = match[7]
|
122
127
|
end
|
123
128
|
ebuff << '\n", ' + args.join(', ') + ")\n"
|
124
129
|
ebuff << "end\n"
|
@@ -1,10 +1,16 @@
|
|
1
|
-
|
1
|
+
$: << File.join("..","src")
|
2
|
+
require "test/unit"
|
3
|
+
require "log4r"
|
4
|
+
include Log4r
|
5
|
+
|
6
|
+
|
7
|
+
class TestPatternFormatter < Test::Unit::TestCase
|
2
8
|
def test_pattern
|
3
9
|
l = Logger.new 'test::this::that'
|
4
10
|
l.trace = true
|
5
11
|
o = StdoutOutputter.new 'test'
|
6
12
|
l.add o
|
7
|
-
|
13
|
+
assert_nothing_raised {
|
8
14
|
f = PatternFormatter.new :pattern=> "%d %6l [%C]%c %% %-40.30M"
|
9
15
|
#:date_pattern=> "%Y"
|
10
16
|
#:date_method => :usec
|
@@ -18,4 +24,55 @@ class TestPatternFormatter < TestCase
|
|
18
24
|
l.info [1, 3, 5]
|
19
25
|
}
|
20
26
|
end
|
27
|
+
|
28
|
+
def test_ndc
|
29
|
+
l = Logger.new 'test::this::that::other'
|
30
|
+
l.trace = true
|
31
|
+
o = StdoutOutputter.new 'testy'
|
32
|
+
l.add o
|
33
|
+
f = PatternFormatter.new :pattern=> "%d %6l [%C]%c {%x} %% %-40.30M"
|
34
|
+
#:date_pattern=> "%Y"
|
35
|
+
#:date_method => :usec
|
36
|
+
Outputter['testy'].formatter = f
|
37
|
+
|
38
|
+
l.info "no NDC"
|
39
|
+
NDC.push("start")
|
40
|
+
l.info "start NDC"
|
41
|
+
NDC.push("finish")
|
42
|
+
l.info "start finish NDC"
|
43
|
+
NDC.pop()
|
44
|
+
l.info "start NDC"
|
45
|
+
NDC.remove()
|
46
|
+
l.info "no NDC"
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_gdc
|
50
|
+
l = Logger.new 'test::this::that::other'
|
51
|
+
l.trace = true
|
52
|
+
o = StdoutOutputter.new 'testy'
|
53
|
+
l.add o
|
54
|
+
f = PatternFormatter.new :pattern=> "%d %6l [%C]%c {%g} %% %-40.30M"
|
55
|
+
#:date_pattern=> "%Y"
|
56
|
+
#:date_method => :usec
|
57
|
+
Outputter['testy'].formatter = f
|
58
|
+
|
59
|
+
l.info "GDC default"
|
60
|
+
GDC.set("non-default")
|
61
|
+
l.info "GDC non-default"
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_mdc
|
65
|
+
l = Logger.new 'test::this::that::other'
|
66
|
+
l.trace = true
|
67
|
+
o = StdoutOutputter.new 'testy'
|
68
|
+
l.add o
|
69
|
+
f = PatternFormatter.new :pattern=> "%d %6l [%C]%c {%X{user}} %% %-40.30M"
|
70
|
+
#:date_pattern=> "%Y"
|
71
|
+
#:date_method => :usec
|
72
|
+
Outputter['testy'].formatter = f
|
73
|
+
|
74
|
+
l.info "no user"
|
75
|
+
MDC.put("user","colbygk")
|
76
|
+
l.info "user colbygk"
|
77
|
+
end
|
21
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colby Gutierrez-Kraybill
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-12 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|