log4r 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/README +3 -3
  2. data/Rakefile +2 -2
  3. data/doc/rdoc/Log4r.html +519 -0
  4. data/doc/rdoc/Log4r/BasicFormatter.html +388 -0
  5. data/doc/rdoc/Log4r/ConfigError.html +225 -0
  6. data/doc/rdoc/Log4r/Configurator.html +1068 -0
  7. data/doc/rdoc/Log4r/DateFileOutputter.html +479 -0
  8. data/doc/rdoc/Log4r/DefaultFormatter.html +223 -0
  9. data/doc/rdoc/Log4r/EmailOutputter.html +654 -0
  10. data/doc/rdoc/Log4r/FileOutputter.html +346 -0
  11. data/doc/rdoc/Log4r/Formatter.html +309 -0
  12. data/doc/rdoc/Log4r/GDC.html +346 -0
  13. data/doc/rdoc/Log4r/GDC_rb.html +80 -0
  14. data/doc/rdoc/Log4r/IOOutputter.html +410 -0
  15. data/doc/rdoc/Log4r/Log4jXmlFormatter.html +337 -0
  16. data/doc/rdoc/Log4r/Log4rConfig.html +211 -0
  17. data/doc/rdoc/Log4r/Log4rTools.html +388 -0
  18. data/doc/rdoc/Log4r/LogEvent.html +378 -0
  19. data/doc/rdoc/Log4r/LogServer.html +340 -0
  20. data/doc/rdoc/Log4r/Logger.html +1150 -0
  21. data/doc/rdoc/Log4r/Logger/LoggerFactory.html +218 -0
  22. data/doc/rdoc/Log4r/Logger/Repository.html +225 -0
  23. data/doc/rdoc/Log4r/MDC.html +424 -0
  24. data/doc/rdoc/Log4r/MDC_rb.html +83 -0
  25. data/doc/rdoc/Log4r/NDC.html +632 -0
  26. data/doc/rdoc/Log4r/NDC_rb.html +110 -0
  27. data/doc/rdoc/Log4r/ObjectFormatter.html +280 -0
  28. data/doc/rdoc/Log4r/Outputter.html +934 -0
  29. data/doc/rdoc/Log4r/Outputter/OutputterFactory.html +218 -0
  30. data/doc/rdoc/Log4r/Outputter/consoleoutputters_rb.html +57 -0
  31. data/doc/rdoc/Log4r/Outputter/datefileoutputter_rb.html +93 -0
  32. data/doc/rdoc/Log4r/Outputter/emailoutputter_rb.html +179 -0
  33. data/doc/rdoc/Log4r/Outputter/fileoutputter_rb.html +64 -0
  34. data/doc/rdoc/Log4r/Outputter/iooutputter_rb.html +59 -0
  35. data/doc/rdoc/Log4r/Outputter/outputter_rb.html +222 -0
  36. data/doc/rdoc/Log4r/Outputter/outputterfactory_rb.html +62 -0
  37. data/doc/rdoc/Log4r/Outputter/remoteoutputter_rb.html +59 -0
  38. data/doc/rdoc/Log4r/Outputter/rollingfileoutputter_rb.html +66 -0
  39. data/doc/rdoc/Log4r/Outputter/staticoutputter_rb.html +55 -0
  40. data/doc/rdoc/Log4r/Outputter/syslogoutputter_rb.html +110 -0
  41. data/doc/rdoc/Log4r/Outputter/udpoutputter_rb.html +220 -0
  42. data/doc/rdoc/Log4r/PatternFormatter.html +404 -0
  43. data/doc/rdoc/Log4r/ROMPClient.html +211 -0
  44. data/doc/rdoc/Log4r/ROMPServer.html +211 -0
  45. data/doc/rdoc/Log4r/RemoteOutputter.html +402 -0
  46. data/doc/rdoc/Log4r/RollingFileOutputter.html +551 -0
  47. data/doc/rdoc/Log4r/RootLogger.html +530 -0
  48. data/doc/rdoc/Log4r/SimpleFormatter.html +276 -0
  49. data/doc/rdoc/Log4r/StderrOutputter.html +268 -0
  50. data/doc/rdoc/Log4r/StdoutOutputter.html +268 -0
  51. data/doc/rdoc/Log4r/SyslogOutputter.html +551 -0
  52. data/doc/rdoc/Log4r/UDPOutputter.html +379 -0
  53. data/doc/rdoc/Log4r/YamlConfigurator.html +966 -0
  54. data/doc/rdoc/Log4r/base_rb.html +57 -0
  55. data/doc/rdoc/Log4r/config_rb.html +122 -0
  56. data/doc/rdoc/Log4r/configurator_rb.html +370 -0
  57. data/doc/rdoc/Log4r/formatter/formatter_rb.html +121 -0
  58. data/doc/rdoc/Log4r/formatter/log4jxmlformatter_rb.html +64 -0
  59. data/doc/rdoc/Log4r/formatter/patternformatter_rb.html +239 -0
  60. data/doc/rdoc/Log4r/lib/drbloader_rb.html +57 -0
  61. data/doc/rdoc/Log4r/lib/xmlloader_rb.html +57 -0
  62. data/doc/rdoc/Log4r/logevent_rb.html +55 -0
  63. data/doc/rdoc/Log4r/logger_rb.html +293 -0
  64. data/doc/rdoc/Log4r/loggerfactory_rb.html +66 -0
  65. data/doc/rdoc/Log4r/logserver_rb.html +161 -0
  66. data/doc/rdoc/Log4r/rdoc/GDC.html +175 -0
  67. data/doc/rdoc/Log4r/rdoc/MDC.html +178 -0
  68. data/doc/rdoc/Log4r/rdoc/NDC.html +207 -0
  69. data/doc/rdoc/Log4r/rdoc/configurator.html +462 -0
  70. data/doc/rdoc/Log4r/rdoc/emailoutputter.html +279 -0
  71. data/doc/rdoc/Log4r/rdoc/formatter.html +218 -0
  72. data/doc/rdoc/Log4r/rdoc/log4r.html +286 -0
  73. data/doc/rdoc/Log4r/rdoc/logger.html +382 -0
  74. data/doc/rdoc/Log4r/rdoc/logserver.html +265 -0
  75. data/doc/rdoc/Log4r/rdoc/outputter.html +313 -0
  76. data/doc/rdoc/Log4r/rdoc/patternformatter.html +331 -0
  77. data/doc/rdoc/Log4r/rdoc/syslogoutputter.html +197 -0
  78. data/doc/rdoc/Log4r/rdoc/win32eventoutputter.html +165 -0
  79. data/doc/rdoc/Log4r/rdoc/yamlconfigurator.html +187 -0
  80. data/doc/rdoc/Log4r/repository_rb.html +74 -0
  81. data/doc/rdoc/Log4r/staticlogger_rb.html +55 -0
  82. data/doc/rdoc/Log4r/yamlconfigurator_rb.html +95 -0
  83. data/doc/rdoc/REXML.html +211 -0
  84. data/doc/rdoc/created.rid +1 -0
  85. data/doc/rdoc/images/brick.png +0 -0
  86. data/doc/rdoc/images/brick_link.png +0 -0
  87. data/doc/rdoc/images/bug.png +0 -0
  88. data/doc/rdoc/images/bullet_black.png +0 -0
  89. data/doc/rdoc/images/bullet_toggle_minus.png +0 -0
  90. data/doc/rdoc/images/bullet_toggle_plus.png +0 -0
  91. data/doc/rdoc/images/date.png +0 -0
  92. data/doc/rdoc/images/find.png +0 -0
  93. data/doc/rdoc/images/loadingAnimation.gif +0 -0
  94. data/doc/rdoc/images/macFFBgHack.png +0 -0
  95. data/doc/rdoc/images/package.png +0 -0
  96. data/doc/rdoc/images/page_green.png +0 -0
  97. data/doc/rdoc/images/page_white_text.png +0 -0
  98. data/doc/rdoc/images/page_white_width.png +0 -0
  99. data/doc/rdoc/images/plugin.png +0 -0
  100. data/doc/rdoc/images/ruby.png +0 -0
  101. data/doc/rdoc/images/tag_green.png +0 -0
  102. data/doc/rdoc/images/wrench.png +0 -0
  103. data/doc/rdoc/images/wrench_orange.png +0 -0
  104. data/doc/rdoc/images/zoom.png +0 -0
  105. data/doc/rdoc/index.html +585 -0
  106. data/doc/rdoc/js/darkfish.js +116 -0
  107. data/doc/rdoc/js/jquery.js +32 -0
  108. data/doc/rdoc/js/quicksearch.js +114 -0
  109. data/doc/rdoc/js/thickbox-compressed.js +10 -0
  110. data/doc/rdoc/log4r-rdoc.css +696 -0
  111. data/doc/rdoc/log4r_rb.html +207 -0
  112. data/doc/rdoc/rdoc.css +696 -0
  113. data/examples/rdoc-gen +2 -0
  114. data/src/log4r.rb +2 -2
  115. data/src/log4r/formatter/patternformatter.rb +15 -15
  116. data/src/log4r/outputter/udpoutputter.rb +4 -4
  117. data/tests/testchainsaw.rb +1 -1
  118. metadata +123 -8
  119. data/src/log4r/outputter/datefileoutputter.patch +0 -24
  120. data/src/log4r/outputter/diff +0 -14
  121. data/src/log4r/outputter/new-datefileoutputter.rb +0 -117
@@ -0,0 +1,2 @@
1
+ rdoc --exclude *CVS* --exclude .*patch --exclude diff
2
+
@@ -3,7 +3,7 @@
3
3
  # == Other Info
4
4
  #
5
5
  # Author:: Leon Torres
6
- # Version:: $Id: log4r.rb,v 1.9 2010/03/11 22:59:51 colbygk Exp $
6
+ # Version:: $Id: log4r.rb,v 1.10 2010/03/12 17:54:27 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, 6].join '.'
19
+ Log4rVersion = [1, 1, 7].join '.'
20
20
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: patternformatter.rb,v 1.8 2010/01/12 09:28:49 colbygk Exp $
5
+ # Version:: $Id: patternformatter.rb,v 1.9 2010/03/12 04:04:54 colbygk Exp $
6
6
 
7
7
  require "log4r/formatter/formatter"
8
8
  require "log4r/GDC"
@@ -13,20 +13,20 @@ module Log4r
13
13
  # See log4r/formatter/patternformatter.rb
14
14
  class PatternFormatter < BasicFormatter
15
15
 
16
- # Arguments to sprintf keyed to directive letters
17
- # %c - event short name
18
- # %C - event fullname
19
- # %d - date
20
- # %g - Global Diagnostic Context (GDC)
21
- # %t - trace
22
- # %m - message
23
- # %h - thread name
24
- # %p - process ID aka PID
25
- # %M - formatted message
26
- # %l - Level in string form
27
- # %x - Nested Diagnostic Context (NDC)
28
- # %X - Mapped Diagnostic Context (MDC), syntax is "%X.key"
29
- # %% - Insert a %
16
+ # Arguments to sprintf keyed to directive letters<br>
17
+ # %c - event short name<br>
18
+ # %C - event fullname<br>
19
+ # %d - date<br>
20
+ # %g - Global Diagnostic Context (GDC)<br>
21
+ # %t - trace<br>
22
+ # %m - message<br>
23
+ # %h - thread name<br>
24
+ # %p - process ID aka PID<br>
25
+ # %M - formatted message<br>
26
+ # %l - Level in string form<br>
27
+ # %x - Nested Diagnostic Context (NDC)<br>
28
+ # %X - Mapped Diagnostic Context (MDC), syntax is "%X{key}"<br>
29
+ # %% - Insert a %<br>
30
30
  DirectiveTable = {
31
31
  "c" => 'event.name',
32
32
  "C" => 'event.fullname',
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # == Other Info
4
4
  #
5
- # Version:: $Id: udpoutputter.rb,v 1.2 2010/03/11 23:38:36 colbygk Exp $
5
+ # Version:: $Id: udpoutputter.rb,v 1.3 2010/03/12 17:35:06 colbygk Exp $
6
6
  # Author:: Leon Torres <leon@ugcs.caltech.edu>
7
7
 
8
8
  require "log4r/outputter/outputter"
@@ -15,10 +15,10 @@ module Log4r
15
15
  attr_reader :host, :port
16
16
  attr_accessor :udpsock
17
17
 
18
- def initialize(_name, _host, _port, hash={})
18
+ def initialize(_name, hash={})
19
19
  super(_name, hash)
20
- @host = _host
21
- @port = _port
20
+ @host = hash[:hostname]
21
+ @port = hash[:port]
22
22
 
23
23
  begin
24
24
  Logger.log_internal {
@@ -14,7 +14,7 @@ log4r.outputters = StdoutOutputter.new 'log4r'
14
14
  log4r.level = ALL
15
15
 
16
16
  formatter = Log4jXmlFormatter.new
17
- outputter = UDPOutputter.new 'udp', "localhost", 8071
17
+ outputter = UDPOutputter.new 'udp', :hostname => "localhost", :port => 8071
18
18
  outputter.formatter = formatter
19
19
 
20
20
  mylog = Logger.new 'mylog'
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 1
8
+ - 7
9
+ version: 1.1.7
5
10
  platform: ruby
6
11
  authors:
7
12
  - Colby Gutierrez-Kraybill
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-11 00:00:00 -08:00
17
+ date: 2010-03-12 00:00:00 -08:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -41,6 +46,116 @@ files:
41
46
  - doc/images/log4r-logo.png
42
47
  - doc/images/logo2.png
43
48
  - doc/log4r.css
49
+ - doc/rdoc/created.rid
50
+ - doc/rdoc/images/brick.png
51
+ - doc/rdoc/images/brick_link.png
52
+ - doc/rdoc/images/bug.png
53
+ - doc/rdoc/images/bullet_black.png
54
+ - doc/rdoc/images/bullet_toggle_minus.png
55
+ - doc/rdoc/images/bullet_toggle_plus.png
56
+ - doc/rdoc/images/date.png
57
+ - doc/rdoc/images/find.png
58
+ - doc/rdoc/images/loadingAnimation.gif
59
+ - doc/rdoc/images/macFFBgHack.png
60
+ - doc/rdoc/images/package.png
61
+ - doc/rdoc/images/page_green.png
62
+ - doc/rdoc/images/page_white_text.png
63
+ - doc/rdoc/images/page_white_width.png
64
+ - doc/rdoc/images/plugin.png
65
+ - doc/rdoc/images/ruby.png
66
+ - doc/rdoc/images/tag_green.png
67
+ - doc/rdoc/images/wrench.png
68
+ - doc/rdoc/images/wrench_orange.png
69
+ - doc/rdoc/images/zoom.png
70
+ - doc/rdoc/index.html
71
+ - doc/rdoc/js/darkfish.js
72
+ - doc/rdoc/js/jquery.js
73
+ - doc/rdoc/js/quicksearch.js
74
+ - doc/rdoc/js/thickbox-compressed.js
75
+ - doc/rdoc/Log4r/base_rb.html
76
+ - doc/rdoc/Log4r/BasicFormatter.html
77
+ - doc/rdoc/Log4r/config_rb.html
78
+ - doc/rdoc/Log4r/ConfigError.html
79
+ - doc/rdoc/Log4r/Configurator.html
80
+ - doc/rdoc/Log4r/configurator_rb.html
81
+ - doc/rdoc/Log4r/DateFileOutputter.html
82
+ - doc/rdoc/Log4r/DefaultFormatter.html
83
+ - doc/rdoc/Log4r/EmailOutputter.html
84
+ - doc/rdoc/Log4r/FileOutputter.html
85
+ - doc/rdoc/Log4r/formatter/formatter_rb.html
86
+ - doc/rdoc/Log4r/formatter/log4jxmlformatter_rb.html
87
+ - doc/rdoc/Log4r/formatter/patternformatter_rb.html
88
+ - doc/rdoc/Log4r/Formatter.html
89
+ - doc/rdoc/Log4r/GDC.html
90
+ - doc/rdoc/Log4r/GDC_rb.html
91
+ - doc/rdoc/Log4r/IOOutputter.html
92
+ - doc/rdoc/Log4r/lib/drbloader_rb.html
93
+ - doc/rdoc/Log4r/lib/xmlloader_rb.html
94
+ - doc/rdoc/Log4r/Log4jXmlFormatter.html
95
+ - doc/rdoc/Log4r/Log4rConfig.html
96
+ - doc/rdoc/Log4r/Log4rTools.html
97
+ - doc/rdoc/Log4r/LogEvent.html
98
+ - doc/rdoc/Log4r/logevent_rb.html
99
+ - doc/rdoc/Log4r/Logger/LoggerFactory.html
100
+ - doc/rdoc/Log4r/Logger/Repository.html
101
+ - doc/rdoc/Log4r/Logger.html
102
+ - doc/rdoc/Log4r/logger_rb.html
103
+ - doc/rdoc/Log4r/loggerfactory_rb.html
104
+ - doc/rdoc/Log4r/LogServer.html
105
+ - doc/rdoc/Log4r/logserver_rb.html
106
+ - doc/rdoc/Log4r/MDC.html
107
+ - doc/rdoc/Log4r/MDC_rb.html
108
+ - doc/rdoc/Log4r/NDC.html
109
+ - doc/rdoc/Log4r/NDC_rb.html
110
+ - doc/rdoc/Log4r/ObjectFormatter.html
111
+ - doc/rdoc/Log4r/Outputter/consoleoutputters_rb.html
112
+ - doc/rdoc/Log4r/Outputter/datefileoutputter_rb.html
113
+ - doc/rdoc/Log4r/Outputter/emailoutputter_rb.html
114
+ - doc/rdoc/Log4r/Outputter/fileoutputter_rb.html
115
+ - doc/rdoc/Log4r/Outputter/iooutputter_rb.html
116
+ - doc/rdoc/Log4r/Outputter/outputter_rb.html
117
+ - doc/rdoc/Log4r/Outputter/OutputterFactory.html
118
+ - doc/rdoc/Log4r/Outputter/outputterfactory_rb.html
119
+ - doc/rdoc/Log4r/Outputter/remoteoutputter_rb.html
120
+ - doc/rdoc/Log4r/Outputter/rollingfileoutputter_rb.html
121
+ - doc/rdoc/Log4r/Outputter/staticoutputter_rb.html
122
+ - doc/rdoc/Log4r/Outputter/syslogoutputter_rb.html
123
+ - doc/rdoc/Log4r/Outputter/udpoutputter_rb.html
124
+ - doc/rdoc/Log4r/Outputter.html
125
+ - doc/rdoc/Log4r/PatternFormatter.html
126
+ - doc/rdoc/Log4r/rdoc/configurator.html
127
+ - doc/rdoc/Log4r/rdoc/emailoutputter.html
128
+ - doc/rdoc/Log4r/rdoc/formatter.html
129
+ - doc/rdoc/Log4r/rdoc/GDC.html
130
+ - doc/rdoc/Log4r/rdoc/log4r.html
131
+ - doc/rdoc/Log4r/rdoc/logger.html
132
+ - doc/rdoc/Log4r/rdoc/logserver.html
133
+ - doc/rdoc/Log4r/rdoc/MDC.html
134
+ - doc/rdoc/Log4r/rdoc/NDC.html
135
+ - doc/rdoc/Log4r/rdoc/outputter.html
136
+ - doc/rdoc/Log4r/rdoc/patternformatter.html
137
+ - doc/rdoc/Log4r/rdoc/syslogoutputter.html
138
+ - doc/rdoc/Log4r/rdoc/win32eventoutputter.html
139
+ - doc/rdoc/Log4r/rdoc/yamlconfigurator.html
140
+ - doc/rdoc/Log4r/RemoteOutputter.html
141
+ - doc/rdoc/Log4r/repository_rb.html
142
+ - doc/rdoc/Log4r/RollingFileOutputter.html
143
+ - doc/rdoc/Log4r/ROMPClient.html
144
+ - doc/rdoc/Log4r/ROMPServer.html
145
+ - doc/rdoc/Log4r/RootLogger.html
146
+ - doc/rdoc/Log4r/SimpleFormatter.html
147
+ - doc/rdoc/Log4r/staticlogger_rb.html
148
+ - doc/rdoc/Log4r/StderrOutputter.html
149
+ - doc/rdoc/Log4r/StdoutOutputter.html
150
+ - doc/rdoc/Log4r/SyslogOutputter.html
151
+ - doc/rdoc/Log4r/UDPOutputter.html
152
+ - doc/rdoc/Log4r/YamlConfigurator.html
153
+ - doc/rdoc/Log4r/yamlconfigurator_rb.html
154
+ - doc/rdoc/log4r-rdoc.css
155
+ - doc/rdoc/Log4r.html
156
+ - doc/rdoc/log4r_rb.html
157
+ - doc/rdoc/rdoc.css
158
+ - doc/rdoc/REXML.html
44
159
  - doc/rdoc-log4r.css
45
160
  - doc/templates/main.html
46
161
  - examples/chainsaw_settings.xml
@@ -54,6 +169,7 @@ files:
54
169
  - examples/moderateconfig.rb
55
170
  - examples/myformatter.rb
56
171
  - examples/outofthebox.rb
172
+ - examples/rdoc-gen
57
173
  - examples/README
58
174
  - examples/rrconfig.xml
59
175
  - examples/rrsetup.rb
@@ -77,13 +193,10 @@ files:
77
193
  - src/log4r/MDC.rb
78
194
  - src/log4r/NDC.rb
79
195
  - src/log4r/outputter/consoleoutputters.rb
80
- - src/log4r/outputter/datefileoutputter.patch
81
196
  - src/log4r/outputter/datefileoutputter.rb
82
- - src/log4r/outputter/diff
83
197
  - src/log4r/outputter/emailoutputter.rb
84
198
  - src/log4r/outputter/fileoutputter.rb
85
199
  - src/log4r/outputter/iooutputter.rb
86
- - src/log4r/outputter/new-datefileoutputter.rb
87
200
  - src/log4r/outputter/outputter.rb
88
201
  - src/log4r/outputter/outputterfactory.rb
89
202
  - src/log4r/outputter/remoteoutputter.rb
@@ -137,18 +250,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
250
  requirements:
138
251
  - - ">="
139
252
  - !ruby/object:Gem::Version
253
+ segments:
254
+ - 0
140
255
  version: "0"
141
- version:
142
256
  required_rubygems_version: !ruby/object:Gem::Requirement
143
257
  requirements:
144
258
  - - ">="
145
259
  - !ruby/object:Gem::Version
260
+ segments:
261
+ - 0
146
262
  version: "0"
147
- version:
148
263
  requirements: []
149
264
 
150
265
  rubyforge_project: log4r
151
- rubygems_version: 1.3.5
266
+ rubygems_version: 1.3.6
152
267
  signing_key:
153
268
  specification_version: 3
154
269
  summary: Log4r, logging framework for ruby
@@ -1,24 +0,0 @@
1
- --- datefileoutputter.rb 2004-03-18 19:31:09.000000000 -0800
2
- +++ new-datefileoutputter.rb 2010-03-11 18:36:37.000000000 -0800
3
- @@ -54,12 +54,19 @@
4
- if not FileTest.directory?( _dirname)
5
- raise StandardError, "'#{_dirname}' must be a valid directory", caller
6
- end
7
- + end
8
- +
9
- + _filename = (hash[:filename] or hash['filename'])
10
- + if _filename.nil?
11
- @filebase = File.basename( $0, '.rb') + ".log"
12
- else
13
- @filebase = File.basename((hash[:filename] or hash['filename'] or ""))
14
- end
15
- - hash['filename'] = File.join(_dirname,
16
- - @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1'))
17
- +
18
- + # Get rid of the 'nil' in the path
19
- + path = [_dirname, @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1')].compact
20
- + hash[:filename] = hash['filename'] = File.join(path)
21
- +
22
- super(_name, hash)
23
- end
24
-
@@ -1,14 +0,0 @@
1
- 56a57,60
2
- > end
3
- >
4
- > _filename = (hash[:filename] or hash['filename'])
5
- > if _filename.nil?
6
- 61,62c65,69
7
- < hash['filename'] = File.join(_dirname,
8
- < @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1'))
9
- ---
10
- >
11
- > # Get rid of the 'nil' in the path
12
- > path = [_dirname, @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1')].compact
13
- > hash[:filename] = hash['filename'] = File.join(path)
14
- >
@@ -1,117 +0,0 @@
1
- # = DateFileOutputter
2
- #
3
- # Subclass of FileOutputter that changes the log file daily. When a new
4
- # day begins, a new file is created with the date included in the name.
5
- #
6
- # == Usage
7
- #
8
- # df_out = DateFileOutputter.new('name',
9
- # :dirname="/tmp", :date_pattern=>"%m-%d"
10
- # )
11
- #
12
- # == Rate of Change
13
- #
14
- # A new logfile is created whenever the current time as formatted by the date
15
- # pattern no longer matches the previous time. (This is a simple String
16
- # comparison.) So, in order to change the frequency of the rollover, just
17
- # alter the date pattern to match how fast the files should be generated.
18
- # For instance, to generate files by the minute,
19
- #
20
- # df_out.date_pattern = "%M"
21
- #
22
- # This causes the following files to show up one minute apart, asuming the
23
- # script starts at the 4th minute of the hour:
24
- #
25
- # file_04.rb
26
- # file_05.rb
27
- # file_06.rb
28
- # ...
29
- #
30
- # The only limitation of this approach is that the precise time cannot be
31
- # recorded as the smallest time interval equals the rollover period for this
32
- # system.
33
-
34
- require "log4r/outputter/fileoutputter"
35
- require "log4r/staticlogger"
36
-
37
- module Log4r
38
-
39
- # Additional hash arguments are:
40
- #
41
- # [<tt>:dirname</tt>] Directory of the log file
42
- # [<tt>:date_pattern</tt>] Time.strftime format string (default is "%Y-%m-%d")
43
-
44
- class DateFileOutputter < FileOutputter
45
- DEFAULT_DATE_FMT = "%Y-%m-%d"
46
-
47
- def initialize(_name, hash={})
48
- @DatePattern = (hash[:date_pattern] or hash['date_pattern'] or
49
- DEFAULT_DATE_FMT)
50
- @DateStamp = Time.now.strftime( @DatePattern);
51
- _dirname = (hash[:dirname] or hash['dirname'])
52
- # hash[:dirname] masks hash[:filename]
53
- if _dirname
54
- if not FileTest.directory?( _dirname)
55
- raise StandardError, "'#{_dirname}' must be a valid directory", caller
56
- end
57
- end
58
-
59
- _filename = (hash[:filename] or hash['filename'])
60
- if _filename.nil?
61
- @filebase = File.basename( $0, '.rb') + ".log"
62
- else
63
- @filebase = File.basename((hash[:filename] or hash['filename'] or ""))
64
- end
65
-
66
- # Get rid of the 'nil' in the path
67
- path = [_dirname, @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1')].compact
68
- hash[:filename] = hash['filename'] = File.join(path)
69
-
70
- super(_name, hash)
71
- end
72
-
73
- #######
74
- private
75
- #######
76
-
77
- # perform the write
78
- def write(data)
79
- change if requiresChange
80
- super
81
- end
82
-
83
- # construct a new filename from the DateStamp
84
- def makeNewFilename
85
- @DateStamp = Time.now.strftime( @DatePattern);
86
- @filename = File.join(File.dirname(@filename),
87
- @filebase.sub(/(\.\w*)$/, "_#{@DateStamp}" + '\1'))
88
- end
89
-
90
- # does the file require a change?
91
- def requiresChange
92
- _DateStamp = Time.now.strftime( @DatePattern);
93
- if not _DateStamp == @DateStamp
94
- @DateStamp = _DateStamp
95
- return true
96
- end
97
- false
98
- end
99
-
100
- # change the file
101
- def change
102
- begin
103
- @out.close
104
- rescue
105
- Logger.log_internal {
106
- "DateFileOutputter '#{@name}' could not close #{@filename}"
107
- }
108
- end
109
- makeNewFilename
110
- @out = File.new(@filename, (@trunc ? "w" : "a"))
111
- Logger.log_internal {
112
- "DateFileOutputter '#{@name}' now writing to #{@filename}"
113
- }
114
- end
115
- end
116
-
117
- end