logger 1.4.1 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ddf4801d5f2a31d107d694a433dcd93583d43cc405ee2347ca8054409705c68
4
- data.tar.gz: d42cd2e291492d13dd458afc25b349a2501dbddfba526af27185ec199cc203b2
3
+ metadata.gz: be49be41055335fa90e79c26a714b7176077de04b414def791b1a9524169ad80
4
+ data.tar.gz: f064246f7c9e483f96e9838ace1d079ce0d9acea770eb68d5a492a792157bb83
5
5
  SHA512:
6
- metadata.gz: 1db29e10a929c956f8db43abfbd42ac12edf83f10eff23026041e3c1381929bd571f74c9f900337994c980a9eda9ba9e10ca888f67ba986f3727c9897326c98d
7
- data.tar.gz: 55b2c8e12eac1c2a9b7a0ac41ea7df4be72704c4f8b5396fa8c90e13c1682ca6d6711f9ee903bf386a0283bf02cd68dcb1577737998144536ab137dc8e4ba2ac
6
+ metadata.gz: 8dc3387289106d3f98eda8384351d9486b8ad5bb21e5c58a3932595b101705600b1b66c64666eabab90a11f1d90a4b7f01e6f0ce658249bfb9ede51d76414ef4
7
+ data.tar.gz: 693e411b78fc95e47d008b3ced6247606ebb641f7a17368321e8e0002fa450694267794a620fc76f949ac9cf2a7e5ac8b891416d7d4accb738f8c2c228421388
@@ -12,7 +12,7 @@ class Logger
12
12
  end
13
13
 
14
14
  def call(severity, time, progname, msg)
15
- Format % [severity[0..0], format_datetime(time), $$, severity, progname,
15
+ Format % [severity[0..0], format_datetime(time), Process.pid, severity, progname,
16
16
  msg2str(msg)]
17
17
  end
18
18
 
@@ -135,7 +135,7 @@ class Logger
135
135
  end
136
136
  end
137
137
 
138
- if /mswin|mingw/ =~ RUBY_PLATFORM
138
+ if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
139
139
  def lock_shift_log
140
140
  yield
141
141
  end
data/lib/logger/period.rb CHANGED
@@ -15,8 +15,10 @@ class Logger
15
15
  when 'monthly'
16
16
  t = Time.mktime(now.year, now.month, 1) + SiD * 32
17
17
  return Time.mktime(t.year, t.month, 1)
18
- else
18
+ when 'now', 'everytime'
19
19
  return now
20
+ else
21
+ raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
20
22
  end
21
23
  if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
22
24
  hour = t.hour
@@ -34,8 +36,10 @@ class Logger
34
36
  t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
35
37
  when 'monthly'
36
38
  t = Time.mktime(now.year, now.month, 1) - SiD / 2
37
- else
39
+ when 'now', 'everytime'
38
40
  return now
41
+ else
42
+ raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
39
43
  end
40
44
  Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
41
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Logger
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.3"
5
5
  end
data/lib/logger.rb CHANGED
@@ -304,35 +304,35 @@ class Logger
304
304
 
305
305
  # Returns +true+ iff the current severity level allows for the printing of
306
306
  # +DEBUG+ messages.
307
- def debug?; @level <= DEBUG; end
307
+ def debug?; level <= DEBUG; end
308
308
 
309
309
  # Sets the severity to DEBUG.
310
310
  def debug!; self.level = DEBUG; end
311
311
 
312
312
  # Returns +true+ iff the current severity level allows for the printing of
313
313
  # +INFO+ messages.
314
- def info?; @level <= INFO; end
314
+ def info?; level <= INFO; end
315
315
 
316
316
  # Sets the severity to INFO.
317
317
  def info!; self.level = INFO; end
318
318
 
319
319
  # Returns +true+ iff the current severity level allows for the printing of
320
320
  # +WARN+ messages.
321
- def warn?; @level <= WARN; end
321
+ def warn?; level <= WARN; end
322
322
 
323
323
  # Sets the severity to WARN.
324
324
  def warn!; self.level = WARN; end
325
325
 
326
326
  # Returns +true+ iff the current severity level allows for the printing of
327
327
  # +ERROR+ messages.
328
- def error?; @level <= ERROR; end
328
+ def error?; level <= ERROR; end
329
329
 
330
330
  # Sets the severity to ERROR.
331
331
  def error!; self.level = ERROR; end
332
332
 
333
333
  # Returns +true+ iff the current severity level allows for the printing of
334
334
  # +FATAL+ messages.
335
- def fatal?; @level <= FATAL; end
335
+ def fatal?; level <= FATAL; end
336
336
 
337
337
  # Sets the severity to FATAL.
338
338
  def fatal!; self.level = FATAL; end
@@ -349,14 +349,16 @@ class Logger
349
349
  # === Args
350
350
  #
351
351
  # +logdev+::
352
- # The log device. This is a filename (String) or IO object (typically
353
- # +STDOUT+, +STDERR+, or an open file).
352
+ # The log device. This is a filename (String), IO object (typically
353
+ # +STDOUT+, +STDERR+, or an open file), +nil+ (it writes nothing) or
354
+ # +File::NULL+ (same as +nil+).
354
355
  # +shift_age+::
355
356
  # Number of old log files to keep, *or* frequency of rotation (+daily+,
356
- # +weekly+ or +monthly+). Default value is 0.
357
+ # +weekly+ or +monthly+). Default value is 0, which disables log file
358
+ # rotation.
357
359
  # +shift_size+::
358
- # Maximum logfile size in bytes (only applies when +shift_age+ is a number).
359
- # Defaults to +1048576+ (1MB).
360
+ # Maximum logfile size in bytes (only applies when +shift_age+ is a positive
361
+ # Integer). Defaults to +1048576+ (1MB).
360
362
  # +level+::
361
363
  # Logging severity threshold. Default values is Logger::DEBUG.
362
364
  # +progname+::
@@ -384,7 +386,7 @@ class Logger
384
386
  self.datetime_format = datetime_format
385
387
  self.formatter = formatter
386
388
  @logdev = nil
387
- if logdev
389
+ if logdev && logdev != File::NULL
388
390
  @logdev = LogDevice.new(logdev, shift_age: shift_age,
389
391
  shift_size: shift_size,
390
392
  shift_period_suffix: shift_period_suffix,
@@ -409,7 +411,7 @@ class Logger
409
411
  # Reopen a log device.
410
412
  #
411
413
  def reopen(logdev = nil)
412
- @logdev.reopen(logdev)
414
+ @logdev&.reopen(logdev)
413
415
  self
414
416
  end
415
417
 
@@ -456,7 +458,7 @@ class Logger
456
458
  #
457
459
  def add(severity, message = nil, progname = nil)
458
460
  severity ||= UNKNOWN
459
- if @logdev.nil? or severity < @level
461
+ if @logdev.nil? or severity < level
460
462
  return true
461
463
  end
462
464
  if progname.nil?
data/logger.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  begin
2
2
  require_relative "lib/logger/version"
3
3
  rescue LoadError # Fallback to load version file in ruby core repository
4
- require_relative "logger/version"
4
+ require_relative "version"
5
5
  end
6
6
 
7
7
  Gem::Specification.new do |spec|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.summary = %q{Provides a simple logging utility for outputting messages.}
14
14
  spec.description = %q{Provides a simple logging utility for outputting messages.}
15
15
  spec.homepage = "https://github.com/ruby/logger"
16
- spec.license = "BSD-2-Clause"
16
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
17
17
 
18
18
  spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
19
19
  spec.bindir = "exe"
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = ">= 2.3.0"
24
24
 
25
25
  spec.add_development_dependency "bundler", ">= 0"
26
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rake", ">= 12.3.3"
27
27
  spec.add_development_dependency "test-unit"
28
28
  spec.add_development_dependency "rdoc"
29
29
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  - SHIBATA Hiroshi
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-08-20 00:00:00.000000000 Z
12
+ date: 2020-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -29,16 +29,16 @@ dependencies:
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '10.0'
34
+ version: 12.3.3
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '10.0'
41
+ version: 12.3.3
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: test-unit
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -85,9 +85,10 @@ files:
85
85
  - logger.gemspec
86
86
  homepage: https://github.com/ruby/logger
87
87
  licenses:
88
+ - Ruby
88
89
  - BSD-2-Clause
89
90
  metadata: {}
90
- post_install_message:
91
+ post_install_message:
91
92
  rdoc_options: []
92
93
  require_paths:
93
94
  - lib
@@ -102,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubygems_version: 3.0.3
106
- signing_key:
106
+ rubygems_version: 3.2.2
107
+ signing_key:
107
108
  specification_version: 4
108
109
  summary: Provides a simple logging utility for outputting messages.
109
110
  test_files: []