log4r 1.1.3 → 1.1.4

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/README CHANGED
@@ -1,8 +1,8 @@
1
1
  Log4r - A flexible logging library for Ruby
2
2
 
3
3
 
4
- This release: 1.1.3
5
- Release date: 2009/xx/xx
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.6 2009/09/25 20:34:01 colbygk Exp $
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.6 2009/09/25 20:34:02 colbygk Exp $
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.3"
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
@@ -1 +1,4 @@
1
1
 
2
+ Bring documentation on log4r.rubyforge.net up-to-date with 1.1.4
3
+ Add documentation on Nested, Mapped and Global Diagnostic Contexts
4
+
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.5 2009/09/29 02:43:57 colbygk Exp $
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, 3].join '.'
19
+ Log4rVersion = [1, 1, 4].join '.'
20
20
  end
data/src/log4r/GDC.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: GDC.rb,v 1.1 2010/01/12 02:53:43 colbygk Exp $
5
+ # Version:: $Id: GDC.rb,v 1.2 2010/01/12 08:19:29 colbygk Exp $
6
6
  # Author:: Colby Gutierrez-Kraybill <colby(at)astro.berkeley.edu>
7
7
 
8
8
  module Log4r
data/src/log4r/MDC.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: MDC.rb,v 1.1 2010/01/12 02:21:29 colbygk Exp $
5
+ # Version:: $Id: MDC.rb,v 1.2 2010/01/12 08:19:30 colbygk Exp $
6
6
  # Author:: Colby Gutierrez-Kraybill <colby(at)astro.berkeley.edu>
7
7
 
8
8
  require 'monitor'
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.1 2010/01/12 02:21:29 colbygk Exp $
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.6 2009/10/28 19:55:34 colbygk Exp $
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" => '($4 != "" ? MDC.get($4.to_s)',
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+)?)([cCdtmhpMl%]))?(.*)/
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
- args << DirectiveTable[match[5]] # cull the data for our argument list
120
- break if match[6].empty?
121
- _pattern = match[6]
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
- class TestPatternFormatter < TestCase
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
- assert_no_exception {
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.3
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-11 00:00:00 -08:00
12
+ date: 2010-01-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15