logging 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.7.2 / 2012-04-03
2
+
3
+ Bug Fixes
4
+ - Fixed segmentation fault on exit [issue #30]
5
+ - Fixed syswrite warning when IO contains unflushed data in buffer [issue #31]
6
+ - Added "mingw" to the list of Windows host versions
7
+
1
8
  == 1.7.1 / 2012-03-05
2
9
 
3
10
  Bug Fixes
data/a.rb ADDED
@@ -0,0 +1,10 @@
1
+
2
+ File.open('tmp.txt', 'w') { |io|
3
+ # io.sync = true
4
+ io.syswrite io.sync
5
+ io.syswrite "\n"
6
+
7
+ io.puts "Sync is => #{io.sync}"
8
+
9
+ io.syswrite "test line\n"
10
+ }
data/lib/logging.rb CHANGED
@@ -181,6 +181,7 @@ module Logging
181
181
  def reopen
182
182
  log_internal {'re-opening all appenders'}
183
183
  ::Logging::Appenders.each {|appender| appender.reopen}
184
+ self
184
185
  end
185
186
 
186
187
  # call-seq:
@@ -208,6 +209,7 @@ module Logging
208
209
  #
209
210
  def consolidate( *args )
210
211
  ::Logging::Repository.instance.add_master(*args)
212
+ self
211
213
  end
212
214
 
213
215
  # call-seq:
@@ -258,7 +260,7 @@ module Logging
258
260
  # level to this value will disable all log messages except this highest
259
261
  # level.
260
262
  #
261
- # This method should only be invoked once to configure the logging
263
+ # This method should be invoked only once to configure the logging
262
264
  # levels. It is automatically invoked with the default logging levels
263
265
  # when the first logger is created.
264
266
  #
@@ -329,6 +331,7 @@ module Logging
329
331
  end
330
332
 
331
333
  module_eval "OBJ_FORMAT = :#{f}", __FILE__, __LINE__
334
+ self
332
335
  end
333
336
 
334
337
  # call-seq:
@@ -466,7 +469,7 @@ module Logging
466
469
  ::Logging.show_configuration(io, child, indent)
467
470
  end
468
471
 
469
- nil
472
+ self
470
473
  end
471
474
 
472
475
  # :stopdoc:
@@ -494,11 +497,13 @@ module Logging
494
497
 
495
498
  # Close all appenders
496
499
  def shutdown( *args )
500
+ return unless initialized?
497
501
  log_internal {'shutdown called - closing all appenders'}
498
502
  ::Logging::Appenders.each {|appender| appender.close}
503
+ nil
499
504
  end
500
505
 
501
- # Reset the logging framework to it's uninitialized state
506
+ # Reset the Logging framework to it's uninitialized state
502
507
  def reset
503
508
  ::Logging::Repository.reset
504
509
  ::Logging::Appenders.reset
@@ -508,6 +513,12 @@ module Logging
508
513
  remove_instance_variable :@backtrace if defined? @backtrace
509
514
  remove_const :MAX_LEVEL_LENGTH if const_defined? :MAX_LEVEL_LENGTH
510
515
  remove_const :OBJ_FORMAT if const_defined? :OBJ_FORMAT
516
+ self
517
+ end
518
+
519
+ # Return +true+ if the Logging framework is initialized.
520
+ def initialized?
521
+ const_defined? :MAX_LEVEL_LENGTH
511
522
  end
512
523
  # :startdoc:
513
524
  end
@@ -33,7 +33,7 @@ class Appender
33
33
  # :level => the level at which to log
34
34
  #
35
35
  def initialize( name, opts = {} )
36
- ::Logging.init unless ::Logging.const_defined? :MAX_LEVEL_LENGTH
36
+ ::Logging.init unless ::Logging.initialized?
37
37
 
38
38
  @name = name.to_s
39
39
  @closed = false
@@ -203,7 +203,7 @@ module Logging::Appenders
203
203
  # options.
204
204
  #
205
205
  def configure_buffering( opts )
206
- ::Logging.init unless ::Logging.const_defined? :MAX_LEVEL_LENGTH
206
+ ::Logging.init unless ::Logging.initialized?
207
207
 
208
208
  self.immediate_at = opts.getopt(:immediate_at, '')
209
209
  self.auto_flushing = opts.getopt(:auto_flushing, true)
@@ -34,6 +34,7 @@ module Logging::Appenders
34
34
 
35
35
  @io = io
36
36
  @io.sync = true if io.respond_to? :sync= # syswrite complains if the IO stream is buffered
37
+ @io.flush rescue nil # syswrite also complains if in unbuffered mode and buffer isn't empty
37
38
  @close_method = :close
38
39
 
39
40
  super(name, opts)
@@ -42,7 +42,7 @@ module Logging::Config
42
42
  #
43
43
  def pre_config( config )
44
44
  if config.nil?
45
- ::Logging.init unless ::Logging.const_defined? 'MAX_LEVEL_LENGTH'
45
+ ::Logging.init unless ::Logging.initialized?
46
46
  return
47
47
  end
48
48
 
@@ -28,7 +28,7 @@ class Layout
28
28
  # then <tt>:string</tt> is used.
29
29
  #
30
30
  def initialize( opts = {} )
31
- ::Logging.init unless ::Logging.const_defined? :MAX_LEVEL_LENGTH
31
+ ::Logging.init unless ::Logging.initialized?
32
32
 
33
33
  default = ::Logging.const_defined?('OBJ_FORMAT') ?
34
34
  ::Logging::OBJ_FORMAT : nil
@@ -21,7 +21,7 @@ module Logging
21
21
  # once when the +Repository+ singleton instance is created.
22
22
  #
23
23
  def initialize( )
24
- ::Logging.init unless ::Logging.const_defined? 'MAX_LEVEL_LENGTH'
24
+ ::Logging.init unless ::Logging.initialized?
25
25
 
26
26
  @name = 'root'
27
27
  @appenders = []
data/lib/logging/utils.rb CHANGED
@@ -167,7 +167,7 @@ class File
167
167
 
168
168
  # :stopdoc:
169
169
  conf = defined?(RbConfig) ? RbConfig::CONFIG : Config::CONFIG
170
- if conf['host_os'] =~ /mswin|windows|cygwin/i
170
+ if conf['host_os'] =~ /mswin|windows|cygwin|mingw/i
171
171
  # don't lock files on windows
172
172
  undef :flock?, :flock_sh
173
173
  def flock?() yield; end
data/test/test_logging.rb CHANGED
@@ -141,7 +141,7 @@ module TestLogging
141
141
  def test_init_default
142
142
  assert_equal({}, @levels)
143
143
  assert_equal([], @lnames)
144
- assert_same false, ::Logging.const_defined?(:MAX_LEVEL_LENGTH)
144
+ assert_same false, ::Logging.initialized?
145
145
 
146
146
  ::Logging::Repository.instance
147
147
 
@@ -165,7 +165,7 @@ module TestLogging
165
165
  def test_init_special
166
166
  assert_equal({}, @levels)
167
167
  assert_equal([], @lnames)
168
- assert_same false, ::Logging.const_defined?(:MAX_LEVEL_LENGTH)
168
+ assert_same false, ::Logging.initialized?
169
169
 
170
170
  assert_raise(ArgumentError) {::Logging.init(1, 2, 3, 4)}
171
171
 
@@ -191,7 +191,7 @@ module TestLogging
191
191
  def test_init_all_off
192
192
  assert_equal({}, @levels)
193
193
  assert_equal([], @lnames)
194
- assert_same false, ::Logging.const_defined?(:MAX_LEVEL_LENGTH)
194
+ assert_same false, ::Logging.initialized?
195
195
 
196
196
  ::Logging.init %w(a b all c off d)
197
197
 
data/tmp.txt ADDED
@@ -0,0 +1,3 @@
1
+ false
2
+ test line
3
+ Sync is => false
data/version.txt CHANGED
@@ -1 +1 @@
1
- 1.7.1
1
+ 1.7.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-05 00:00:00.000000000Z
12
+ date: 2012-04-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: little-plugger
16
- requirement: &2154814600 !ruby/object:Gem::Requirement
16
+ requirement: &2155744060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154814600
24
+ version_requirements: *2155744060
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: flexmock
27
- requirement: &2154814120 !ruby/object:Gem::Requirement
27
+ requirement: &2155743520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2154814120
35
+ version_requirements: *2155743520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bones-git
38
- requirement: &2154813700 !ruby/object:Gem::Requirement
38
+ requirement: &2155743060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2154813700
46
+ version_requirements: *2155743060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bones
49
- requirement: &2154813280 !ruby/object:Gem::Requirement
49
+ requirement: &2155742640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 3.7.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2154813280
57
+ version_requirements: *2155742640
58
58
  description: ! 'Logging is a flexible logging library for use in Ruby programs based
59
59
  on the
60
60
 
@@ -69,6 +69,7 @@ extensions: []
69
69
  extra_rdoc_files:
70
70
  - History.txt
71
71
  - README.rdoc
72
+ - tmp.txt
72
73
  files:
73
74
  - .gitignore
74
75
  - .rvmrc
@@ -76,6 +77,7 @@ files:
76
77
  - History.txt
77
78
  - README.rdoc
78
79
  - Rakefile
80
+ - a.rb
79
81
  - data/bad_logging_1.rb
80
82
  - data/bad_logging_2.rb
81
83
  - data/logging.rb
@@ -153,6 +155,7 @@ files:
153
155
  - test/test_root_logger.rb
154
156
  - test/test_stats.rb
155
157
  - test/test_utils.rb
158
+ - tmp.txt
156
159
  - version.txt
157
160
  homepage: http://rubygems.org/gems/logging
158
161
  licenses: []