logback 0.9.15.1 → 0.9.15.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,24 +1,23 @@
1
- === 0.9.15.1 / 2009-02-15
1
+ === 0.9.15.2 (2009-5-8)
2
+ * Added Logback.config_console({}) convenience config method.
3
+ * Use rdoc 2.4.3 and hoe 1.12.2 for build, and general rdoc
4
+ improvements.
2
5
 
6
+ === 0.9.15.1 (2009-2-15)
3
7
  * Upgraded to Logback 0.9.15
4
- * Fixed fuzzy slf4j dependency as "~> 1.5.6.1"
5
-
6
- === 0.9.14.1 / 2009-01-04
8
+ * Fixed fuzzy slf4j dependency as "~> 1.5.6.1"
7
9
 
10
+ === 0.9.14.1 (2009-1-4)
8
11
  * Upgraded to Logback 0.9.14
9
12
 
10
- === 0.9.13.1 / 2008-12-06
11
-
13
+ === 0.9.13.1 (2008-12-6)
12
14
  * Upgraded to Logback 0.9.13
13
15
  * Updated SLF4J dependency to ~> 1.5.6
14
- * LogbackBase -rename-> Logback
15
-
16
- === 0.9.11.1 / 2008-11-01
16
+ * LogbackBase -rename-> Logback
17
17
 
18
+ === 0.9.11.1 (2008-11-1)
18
19
  * Upgraded to Logback 0.9.11
19
- * Updated SLF4J dependency to ~> 1.5.5
20
-
21
- === 0.9.9.1 / 2008-10-08
20
+ * Updated SLF4J dependency to ~> 1.5.5
22
21
 
22
+ === 0.9.9.1 (2008-10-8)
23
23
  * Initial release based on Logback 0.9.9
24
-
data/README.txt CHANGED
@@ -14,11 +14,11 @@ packaged in the slf4j gem.
14
14
 
15
15
  === Logback Ruby
16
16
 
17
- Copyright (C) 2008-2009 David Kellum
17
+ Copyright (c) 2008-2009 David Kellum
18
18
 
19
19
  Logback Ruby is free software: you can redistribute it and/or
20
- modify it under the terms of the
21
- {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
20
+ modify it under the terms of the
21
+ {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
22
22
  as published by the Free Software Foundation, either version 3 of the
23
23
  License, or (at your option) any later version.
24
24
 
@@ -29,9 +29,9 @@ Lesser General Public License for more details.
29
29
 
30
30
  === Logback Java
31
31
 
32
- Logback: the reliable, generic, fast and flexible logging library for Java.
32
+ Logback: the reliable, generic, fast and flexible logging library for Java.
33
33
 
34
- Copyright (C) 2000-2008, QOS.ch
34
+ Copyright (c) 2000-2008, QOS.ch
35
35
 
36
36
  This library is free software, you can redistribute it and/or modify
37
37
  it under the terms of the GNU Lesser General Public License as
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- ruby -*-
2
2
  #--
3
- # Copyright (C) 2008 David Kellum
3
+ # Copyright (C) 2008-2009 David Kellum
4
4
  #
5
5
  # Logback Ruby is free software: you can redistribute it and/or
6
- # modify it under the terms of the
7
- # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
6
+ # modify it under the terms of the
7
+ # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
8
8
  # as published by the Free Software Foundation, either version 3 of the
9
9
  # License, or (at your option) any later version.
10
10
  #
@@ -22,14 +22,14 @@ require 'hoe'
22
22
  $LOAD_PATH << './lib'
23
23
  require 'logback/base'
24
24
 
25
- JARS = %w{ core classic access }.map do |n|
25
+ JARS = %w{ core classic access }.map do |n|
26
26
  "logback-#{n}-#{ Logback::LOGBACK_VERSION }.jar"
27
27
  end
28
28
  JAR_FILES = JARS.map { |jar| "lib/logback/#{jar}" }
29
29
 
30
30
  desc "Update the Manifest with actual jars"
31
31
  task :manifest do
32
- out = File.new( 'Manifest.txt', 'w' )
32
+ out = File.new( 'Manifest.txt', 'w' )
33
33
  begin
34
34
  out.write <<END
35
35
  History.txt
@@ -67,7 +67,7 @@ task :mvn_clean do
67
67
  rm_f( JAR_FILES )
68
68
  sh( 'mvn clean' )
69
69
  end
70
- task :clean => :mvn_clean
70
+ task :clean => :mvn_clean
71
71
 
72
72
  task :tag do
73
73
  tag = "logback-#{Logback::VERSION}"
@@ -86,5 +86,4 @@ hoe = Hoe.new( "logback", Logback::VERSION ) do |p|
86
86
  p.developer( "David Kellum", "dek-ruby@gravitext.com" )
87
87
  p.extra_deps << [ 'slf4j', '~> 1.5.6.1' ]
88
88
  p.rubyforge_name = "rjack"
89
- p.rdoc_pattern = /^(lib.*\.(rb|txt))|[^\/]*\.txt$/
90
89
  end
@@ -1,9 +1,9 @@
1
1
  #--
2
- # Copyright (C) 2008 David Kellum
2
+ # Copyright (C) 2008-2009 David Kellum
3
3
  #
4
4
  # Logback Ruby is free software: you can redistribute it and/or
5
- # modify it under the terms of the
6
- # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
5
+ # modify it under the terms of the
6
+ # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
7
7
  # as published by the Free Software Foundation, either version 3 of the
8
8
  # License, or (at your option) any later version.
9
9
  #
@@ -19,14 +19,20 @@ require 'slf4j'
19
19
 
20
20
  require 'logback/base'
21
21
 
22
- # Jruby wrapper module for the Logback[http://logback.qos.ch/] log writer.
22
+ # Jruby wrapper module for the Logback[http://logback.qos.ch/] log writer.
23
23
  # Programmatic configuration and setting of logger output levels is supported.
24
24
  #
25
- # == Example
25
+ # == Examples
26
26
  #
27
- # Logback configuration:
27
+ # === High level configuration
28
28
  #
29
- # require 'slf4j'
29
+ # require 'logback'
30
+ #
31
+ # Logback.config_console( :thread => true, :level => Logback:INFO )
32
+ #
33
+ # === Low level configuration
34
+ #
35
+ # require 'slf4j'
30
36
  # require 'logback'
31
37
  #
32
38
  # log = SLF4J[ 'example' ]
@@ -38,7 +44,7 @@ require 'logback/base'
38
44
  # a.layout = Logback::PatternLayout.new do |p|
39
45
  # p.pattern = "%r %-5level %logger{35} - %msg %ex%n"
40
46
  # end
41
- # end
47
+ # end
42
48
  # Logback.root.add_appender( console )
43
49
  # Logback.root.level = Logback::INFO
44
50
  # end
@@ -48,7 +54,7 @@ require 'logback/base'
48
54
  #
49
55
  # log.debug "...after reconfigure."
50
56
  #
51
- # Configure with Logback XML configuration:
57
+ # Configure with Logback XML configuration:
52
58
  #
53
59
  # Logback.configure do
54
60
  # Logback.load_xml_config( 'sample-logback.xml' )
@@ -69,11 +75,12 @@ require 'logback/base'
69
75
  # +start+. Logback provides many other components not yet extended in
70
76
  # this way. These can be created directly and or extended in a
71
77
  # similar fashion externally. Consider providing a patch to the
72
- # jrack[http://rubyforge.org/projects/rjack] project with any desired
78
+ # rjack[http://rubyforge.org/projects/rjack] project with desired
73
79
  # extensions.
74
80
  #
75
81
  module Logback
76
82
 
83
+ # Load logback jar.
77
84
  def self.require_jar( name )
78
85
  require File.join( LOGBACK_DIR, "#{name}-#{ LOGBACK_VERSION }.jar" )
79
86
  end
@@ -81,43 +88,61 @@ module Logback
81
88
  require_jar 'logback-core'
82
89
  require_jar 'logback-classic'
83
90
 
84
- import 'ch.qos.logback.classic.Level'
91
+ # ch.qos.logback.classic.Level
92
+ Level = Java::ch.qos.logback.classic.Level
85
93
 
94
+ # Level::TRACE
86
95
  TRACE = Level::TRACE
96
+
97
+ # Level::DEBUG
87
98
  DEBUG = Level::DEBUG
88
- INFO = Level::INFO
89
- WARN = Level::WARN
99
+
100
+ # Level::INFO
101
+ INFO = Level::INFO
102
+
103
+ # Level::WARN
104
+ WARN = Level::WARN
105
+
106
+ # Level::ERROR
90
107
  ERROR = Level::ERROR
91
108
 
92
- DEFAULT_PATTERN = "%date [%thread] %-5level %logger{35} - %msg %ex%n"
109
+ DEFAULT_PATTERN = "%date [%thread] %-5level %logger{35} - %msg %ex%n" #:nodoc:
93
110
 
94
111
  @@context = SLF4J.linked_factory
95
112
 
96
- # Returns the LoggerContext
113
+ # Returns the LoggerContext
97
114
  def self.context
98
- @@context
115
+ @@context
99
116
  end
100
117
 
118
+ # Utility mixin of Logback ch.qos.logback.core.spi.LifeCycle instances
101
119
  module Util
120
+ # Start, raise if not started
102
121
  def self.start( lifecycle_obj )
103
122
  lifecycle_obj.start
104
123
  raise "#{lifecycle_obj.class.name} did not start" if ! lifecycle_obj.started?
105
124
  end
106
- end
125
+ end
107
126
 
108
- # Wrapper for
127
+ # Wrapper for
109
128
  # ch.qos.logback.classic.Logger[http://logback.qos.ch/apidocs/ch/qos/logback/classic/Logger.html]
110
129
  class Logger
130
+
131
+ # Initialize given ch.qos.logback.classic.Logger
111
132
  def initialize( jlogger )
112
133
  @jlogger = jlogger
113
134
  end
114
135
 
115
- # Set output level to specified constant (DEBUG,INFO,...)
136
+ # Set output level
137
+ # ==== Parameters
138
+ # :level<Level>:: New output Level.
116
139
  def level=( level )
117
140
  @jlogger.level = level
118
141
  end
119
142
 
120
143
  # Add appender to this logger
144
+ # ==== Parameters
145
+ # :appender<ch.qos.logback.core.Appender>:: Appender
121
146
  def add_appender( appender )
122
147
  @jlogger.add_appender( appender )
123
148
  end
@@ -127,8 +152,9 @@ module Logback
127
152
  @jlogger.additive = is_additive
128
153
  end
129
154
  end
130
-
131
- import 'ch.qos.logback.classic.joran.JoranConfigurator'
155
+
156
+ # ch.qos.logback.classic.joran.JoranConfigurator
157
+ JoranConfigurator = Java::ch.qos.logback.classic.joran.JoranConfigurator
132
158
 
133
159
  # Load the specified Logback (Joran) XML configuration file. Should be
134
160
  # called within a configure {...} block.
@@ -138,19 +164,15 @@ module Logback
138
164
  cfger.doConfigure( file )
139
165
  end
140
166
 
141
- import( 'ch.qos.logback.classic.PatternLayout' ) { 'JPatternLayout' }
167
+ # ch.qos.logback.classic.PatternLayout
168
+ JPatternLayout = Java::ch.qos.logback.classic.PatternLayout
142
169
 
143
- # Extends
144
- # ch.qos.logback.classic.PatternLayout[http://logback.qos.ch/apidocs/ch/qos/logback/access/PatternLayout.html]
145
- # with a block initializer.
170
+ # Extends
171
+ # ch.qos.logback.classic.PatternLayout[http://logback.qos.ch/apidocs/ch/qos/logback/access/PatternLayout.html]
172
+ # with a block initializer.
146
173
  class PatternLayout < JPatternLayout
147
174
 
148
175
  # Sets context and pattern, yields self to block, and calls self.start
149
- #
150
- # :call-seq:
151
- # new(pattern=DEFAULT_PATTERN) -> PatternLayout
152
- # new(pattern=DEFAULT_PATTERN) { |self| ... } -> PatternLayout
153
- #
154
176
  def initialize( pattern=DEFAULT_PATTERN )
155
177
  super()
156
178
  self.context = Logback.context
@@ -160,48 +182,48 @@ module Logback
160
182
  end
161
183
  end
162
184
 
185
+ # Utility implementation mixin for Appenders.
163
186
  module AppenderUtil
164
187
  @@default_layout = Logback::PatternLayout.new
165
188
 
189
+ # Set appender defaults.
166
190
  def set_defaults
167
191
  self.context = Logback.context
168
192
  self.name = self.class.name
169
193
  self.layout = @@default_layout
170
194
  end
171
-
195
+
196
+ # Yield to block, then start.
172
197
  def finish( &block )
173
198
  block.call( self ) unless block.nil?
174
199
  Util.start( self )
175
200
  end
176
201
  end
177
202
 
178
- import( 'ch.qos.logback.core.ConsoleAppender' ) { 'JConsoleAppender' }
203
+ # ch.qos.logback.core.ConsoleAppender
204
+ JConsoleAppender = Java::ch.qos.logback.core.ConsoleAppender
179
205
 
180
- # Extends
206
+ # Extends
181
207
  # ch.qos.logback.core.ConsoleAppender[http://logback.qos.ch/apidocs/ch/qos/logback/core/ConsoleAppender.html]
182
- # with a block initializer.
208
+ # with a block initializer.
183
209
  class ConsoleAppender < JConsoleAppender
184
210
  include AppenderUtil
185
-
211
+
186
212
  # Sets context, default name and layout, yields self to block, and
187
213
  # calls self.start
188
- #
189
- # :call-seq:
190
- # new() -> ConsoleAppender
191
- # new() { |self| ... } -> ConsoleAppender
192
- #
193
214
  def initialize( &block )
194
215
  super()
195
216
  set_defaults
196
217
  finish( &block )
197
218
  end
198
219
  end
199
-
200
- import( 'ch.qos.logback.core.FileAppender' ) { 'JFileAppender' }
201
220
 
202
- # Extends
221
+ # ch.qos.logback.core.FileAppender
222
+ JFileAppender = Java::ch.qos.logback.core.FileAppender
223
+
224
+ # Extends
203
225
  # ch.qos.logback.core.FileAppender[http://logback.qos.ch/apidocs/ch/qos/logback/core/FileAppender.html]
204
- # with a block initializer.
226
+ # with a block initializer.
205
227
  #
206
228
  # Note that if buffered (immediate_flush = false, buffer_size > 0),
207
229
  # you will need to +stop+ the appender before exiting in order to
@@ -215,38 +237,55 @@ module Logback
215
237
  include AppenderUtil
216
238
 
217
239
  # Sets defaults, yields self to block, and calls self.start
218
- #
219
- # :call-seq:
220
- # new(file_name,append = true) -> FileAppender
221
- # new(file_name,append = true) { |self| ... } -> FileAppender
222
- #
223
240
  def initialize( file_name, append = true, &block )
224
241
  super()
225
242
  set_defaults
226
243
  self.file = file_name
227
244
  self.append = append
228
245
  self.immediate_flush = true #default
229
- self.encoding = "UTF-8"
246
+ self.encoding = "UTF-8"
230
247
  finish( &block )
231
248
  end
232
249
  end
233
250
 
234
251
  # Configure Logback with the specified block. The Logback context is
235
- # +reset+ before yielding, and then started after return
252
+ # +reset+, yielded to block, and then started after return
236
253
  # from the block.
237
- #
238
- # :call-seq:
239
- # configure { |context| ... } -> nil
240
- #
241
254
  def self.configure
242
255
  @@context.reset
243
256
 
244
- yield( context )
257
+ yield context
245
258
 
246
259
  Util.start( context )
247
260
  nil
248
261
  end
249
262
 
263
+ # Configure a single ConsoleAppender using options hash.
264
+ # ==== Options
265
+ # :stderr:: Output to standard error? (default: false)
266
+ # :full:: Output full date? (default: false, milliseconds)
267
+ # :thread:: Output thread name? (default: false)
268
+ # :level<Level>:: Set root level (default: INFO)
269
+ # :lwidth<~to_s>:: Logger width (default: :full ? 35 : 30)
270
+ def self.config_console( options = {} )
271
+ configure do
272
+ console = Logback::ConsoleAppender.new do |a|
273
+ a.target = "System.err" if options[ :stderr ]
274
+ a.layout = Logback::PatternLayout.new do |layout|
275
+ pat = [ options[ :full ] ? '%date' : '%-4r' ]
276
+ pat << '[%thread]' if options[ :thread ]
277
+ pat << '%-5level'
278
+ w = ( options[ :lwidth ] || ( options[ :full ] ? 35 : 30 ) )
279
+ pat << "%logger{#{w}}"
280
+ pat += [ '-', '%msg' '%ex%n' ]
281
+ layout.pattern = pat.join( ' ' )
282
+ end
283
+ end
284
+ Logback.root.add_appender( console )
285
+ Logback.root.level = options[ :level ] || INFO
286
+ end
287
+ end
288
+
250
289
  # Returns the named Logger
251
290
  def self.logger( name )
252
291
  Logger.new( @@context.getLogger( name ) )
@@ -2,8 +2,8 @@
2
2
  # Copyright (C) 2008 David Kellum
3
3
  #
4
4
  # Logback Ruby is free software: you can redistribute it and/or
5
- # modify it under the terms of the
6
- # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
5
+ # modify it under the terms of the
6
+ # {GNU Lesser General Public License}[http://www.gnu.org/licenses/lgpl.html]
7
7
  # as published by the Free Software Foundation, either version 3 of the
8
8
  # License, or (at your option) any later version.
9
9
  #
@@ -14,8 +14,11 @@
14
14
  #++
15
15
 
16
16
  module Logback
17
+ # Logback java version
17
18
  LOGBACK_VERSION = '0.9.15'
18
- VERSION = LOGBACK_VERSION + '.1'
19
+
20
+ # Logback gem version
21
+ VERSION = LOGBACK_VERSION + '.2'
19
22
 
20
23
  LOGBACK_DIR = File.dirname(__FILE__) # :nodoc:
21
24
  end
File without changes
metadata CHANGED
@@ -58,12 +58,12 @@ requirements: []
58
58
 
59
59
  authors:
60
60
  - David Kellum
61
- date: 2009-02-15 08:00:00 +00:00
61
+ date: 2009-05-08 08:00:00 +00:00
62
62
  platform: ruby
63
63
  test_files:
64
64
  - test/test_logback.rb
65
65
  version: !ruby/object:Gem::Version
66
- version: 0.9.15.1
66
+ version: 0.9.15.2
67
67
  require_paths:
68
68
  - lib
69
69
  dependencies:
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - '>='
84
84
  - !ruby/object:Gem::Version
85
- version: 1.8.2
85
+ version: 1.12.2
86
86
  version:
87
87
  type: :development
88
88
  version_requirement: