logger 1.4.1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logger/formatter.rb +4 -3
- data/lib/logger/log_device.rb +1 -1
- data/lib/logger/period.rb +6 -2
- data/lib/logger/version.rb +1 -1
- data/lib/logger.rb +20 -18
- data/logger.gemspec +3 -5
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdee784517977e63d746c2ea95367978a203a68472dfdbaac094e49b291ce170
|
4
|
+
data.tar.gz: a80c2295c6ea2d146f6a21f9d2c76320a0bedebac7261c88785a7e45f3a7f91e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8af19f1a91db15b14c9a3db994184b0b918db2dae08380813495b135f5cbf7d55563d75a155ba3924b023b7123c7934343bad913880c2b5511e34c99e86972
|
7
|
+
data.tar.gz: 0eb96b3097cc63f8fbcda65de469effd3355f6381152b1e8344c35f2222e91c51adc669bc8c1ccc28a5706efdbea0b07926326e35a9dfa8fad1c545101485b9b
|
data/lib/logger/formatter.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
class Logger
|
4
4
|
# Default formatter for log messages.
|
5
5
|
class Formatter
|
6
|
-
Format = "%s, [%s#%d] %5s -- %s: %s\n"
|
6
|
+
Format = "%s, [%s #%d] %5s -- %s: %s\n"
|
7
|
+
DatetimeFormat = "%Y-%m-%dT%H:%M:%S.%6N"
|
7
8
|
|
8
9
|
attr_accessor :datetime_format
|
9
10
|
|
@@ -12,14 +13,14 @@ class Logger
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(severity, time, progname, msg)
|
15
|
-
Format % [severity[0..0], format_datetime(time),
|
16
|
+
Format % [severity[0..0], format_datetime(time), Process.pid, severity, progname,
|
16
17
|
msg2str(msg)]
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
20
21
|
|
21
22
|
def format_datetime(time)
|
22
|
-
time.strftime(@datetime_format ||
|
23
|
+
time.strftime(@datetime_format || DatetimeFormat)
|
23
24
|
end
|
24
25
|
|
25
26
|
def msg2str(msg)
|
data/lib/logger/log_device.rb
CHANGED
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
|
-
|
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
|
-
|
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
|
data/lib/logger/version.rb
CHANGED
data/lib/logger.rb
CHANGED
@@ -302,37 +302,37 @@ class Logger
|
|
302
302
|
alias sev_threshold level
|
303
303
|
alias sev_threshold= level=
|
304
304
|
|
305
|
-
# Returns +true+
|
305
|
+
# Returns +true+ if and only if the current severity level allows for the printing of
|
306
306
|
# +DEBUG+ messages.
|
307
|
-
def debug?;
|
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
|
-
# Returns +true+
|
312
|
+
# Returns +true+ if and only if the current severity level allows for the printing of
|
313
313
|
# +INFO+ messages.
|
314
|
-
def info?;
|
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
|
-
# Returns +true+
|
319
|
+
# Returns +true+ if and only if the current severity level allows for the printing of
|
320
320
|
# +WARN+ messages.
|
321
|
-
def warn?;
|
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
|
-
# Returns +true+
|
326
|
+
# Returns +true+ if and only if the current severity level allows for the printing of
|
327
327
|
# +ERROR+ messages.
|
328
|
-
def error?;
|
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
|
-
# Returns +true+
|
333
|
+
# Returns +true+ if and only if the current severity level allows for the printing of
|
334
334
|
# +FATAL+ messages.
|
335
|
-
def fatal?;
|
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)
|
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
|
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
|
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 <
|
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 "
|
4
|
+
require_relative "version"
|
5
5
|
end
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
@@ -13,17 +13,15 @@ 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.
|
16
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
17
17
|
|
18
18
|
spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
|
19
|
-
spec.bindir = "exe"
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
19
|
spec.require_paths = ["lib"]
|
22
20
|
|
23
21
|
spec.required_ruby_version = ">= 2.3.0"
|
24
22
|
|
25
23
|
spec.add_development_dependency "bundler", ">= 0"
|
26
|
-
spec.add_development_dependency "rake", "
|
24
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
27
25
|
spec.add_development_dependency "test-unit"
|
28
26
|
spec.add_development_dependency "rdoc"
|
29
27
|
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
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
- SHIBATA Hiroshi
|
9
|
-
autorequire:
|
10
|
-
bindir:
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-12-20 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:
|
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:
|
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.
|
106
|
-
signing_key:
|
106
|
+
rubygems_version: 3.3.0.dev
|
107
|
+
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Provides a simple logging utility for outputting messages.
|
109
110
|
test_files: []
|