logger 1.6.0 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDL +22 -0
- data/COPYING +56 -0
- data/lib/logger/log_device.rb +8 -1
- data/lib/logger/period.rb +8 -8
- data/lib/logger/version.rb +1 -1
- data/lib/logger.rb +20 -6
- data/logger.gemspec +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 513b3bfa57e4f617976d220ea3ab04b6a72f8ce0f3734b80a2de276b623d6b49
|
4
|
+
data.tar.gz: 26bf01af278a060e23d1d80c83e46d474933d2af9425360223656f62c04c8df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be737e542a0c9763d280be61f8fe045c72db441f4c25032c3ac332c926abf21c0e957dcdabe17f8cc403348636c71c1e0ee5d9220ea9108572b8d3457e1e00f9
|
7
|
+
data.tar.gz: bcc5494d61bda582003ba814ceadce03476ca58cbecad391053b5d7b98538d3ee047bb2cce72efb80af54df0947ec82c9c993124dd91dbb1c421401b356b613f
|
data/BSDL
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/lib/logger/log_device.rb
CHANGED
@@ -11,9 +11,10 @@ class Logger
|
|
11
11
|
attr_reader :filename
|
12
12
|
include MonitorMixin
|
13
13
|
|
14
|
-
def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false)
|
14
|
+
def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false, reraise_write_errors: [])
|
15
15
|
@dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
|
16
16
|
@binmode = binmode
|
17
|
+
@reraise_write_errors = reraise_write_errors
|
17
18
|
mon_initialize
|
18
19
|
set_dev(log)
|
19
20
|
if @filename
|
@@ -34,16 +35,22 @@ class Logger
|
|
34
35
|
if @shift_age and @dev.respond_to?(:stat)
|
35
36
|
begin
|
36
37
|
check_shift_log
|
38
|
+
rescue *@reraise_write_errors
|
39
|
+
raise
|
37
40
|
rescue
|
38
41
|
warn("log shifting failed. #{$!}")
|
39
42
|
end
|
40
43
|
end
|
41
44
|
begin
|
42
45
|
@dev.write(message)
|
46
|
+
rescue *@reraise_write_errors
|
47
|
+
raise
|
43
48
|
rescue
|
44
49
|
warn("log writing failed. #{$!}")
|
45
50
|
end
|
46
51
|
end
|
52
|
+
rescue *@reraise_write_errors
|
53
|
+
raise
|
47
54
|
rescue Exception => ignored
|
48
55
|
warn("log writing failed. #{ignored}")
|
49
56
|
end
|
data/lib/logger/period.rb
CHANGED
@@ -8,14 +8,14 @@ class Logger
|
|
8
8
|
|
9
9
|
def next_rotate_time(now, shift_age)
|
10
10
|
case shift_age
|
11
|
-
when 'daily'
|
11
|
+
when 'daily', :daily
|
12
12
|
t = Time.mktime(now.year, now.month, now.mday) + SiD
|
13
|
-
when 'weekly'
|
13
|
+
when 'weekly', :weekly
|
14
14
|
t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
|
15
|
-
when 'monthly'
|
15
|
+
when 'monthly', :monthly
|
16
16
|
t = Time.mktime(now.year, now.month, 1) + SiD * 32
|
17
17
|
return Time.mktime(t.year, t.month, 1)
|
18
|
-
when 'now', 'everytime'
|
18
|
+
when 'now', 'everytime', :now, :everytime
|
19
19
|
return now
|
20
20
|
else
|
21
21
|
raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
|
@@ -30,13 +30,13 @@ class Logger
|
|
30
30
|
|
31
31
|
def previous_period_end(now, shift_age)
|
32
32
|
case shift_age
|
33
|
-
when 'daily'
|
33
|
+
when 'daily', :daily
|
34
34
|
t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
|
35
|
-
when 'weekly'
|
35
|
+
when 'weekly', :weekly
|
36
36
|
t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
|
37
|
-
when 'monthly'
|
37
|
+
when 'monthly', :monthly
|
38
38
|
t = Time.mktime(now.year, now.month, 1) - SiD / 2
|
39
|
-
when 'now', 'everytime'
|
39
|
+
when 'now', 'everytime', :now, :everytime
|
40
40
|
return now
|
41
41
|
else
|
42
42
|
raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
|
data/lib/logger/version.rb
CHANGED
data/lib/logger.rb
CHANGED
@@ -381,7 +381,7 @@ class Logger
|
|
381
381
|
|
382
382
|
# Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
|
383
383
|
def level
|
384
|
-
|
384
|
+
level_override[level_key] || @level
|
385
385
|
end
|
386
386
|
|
387
387
|
# Sets the log level; returns +severity+.
|
@@ -406,14 +406,14 @@ class Logger
|
|
406
406
|
# logger.debug { "Hello" }
|
407
407
|
# end
|
408
408
|
def with_level(severity)
|
409
|
-
prev,
|
409
|
+
prev, level_override[level_key] = level, Severity.coerce(severity)
|
410
410
|
begin
|
411
411
|
yield
|
412
412
|
ensure
|
413
413
|
if prev
|
414
|
-
|
414
|
+
level_override[level_key] = prev
|
415
415
|
else
|
416
|
-
|
416
|
+
level_override.delete(level_key)
|
417
417
|
end
|
418
418
|
end
|
419
419
|
end
|
@@ -574,10 +574,14 @@ class Logger
|
|
574
574
|
# - +shift_period_suffix+: sets the format for the filename suffix
|
575
575
|
# for periodic log file rotation; default is <tt>'%Y%m%d'</tt>.
|
576
576
|
# See {Periodic Rotation}[rdoc-ref:Logger@Periodic+Rotation].
|
577
|
+
# - +reraise_write_errors+: An array of exception classes, which will
|
578
|
+
# be reraised if there is an error when writing to the log device.
|
579
|
+
# The default is to swallow all exceptions raised.
|
577
580
|
#
|
578
581
|
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG,
|
579
582
|
progname: nil, formatter: nil, datetime_format: nil,
|
580
|
-
binmode: false, shift_period_suffix: '%Y%m%d'
|
583
|
+
binmode: false, shift_period_suffix: '%Y%m%d',
|
584
|
+
reraise_write_errors: [])
|
581
585
|
self.level = level
|
582
586
|
self.progname = progname
|
583
587
|
@default_formatter = Formatter.new
|
@@ -589,7 +593,8 @@ class Logger
|
|
589
593
|
@logdev = LogDevice.new(logdev, shift_age: shift_age,
|
590
594
|
shift_size: shift_size,
|
591
595
|
shift_period_suffix: shift_period_suffix,
|
592
|
-
binmode: binmode
|
596
|
+
binmode: binmode,
|
597
|
+
reraise_write_errors: reraise_write_errors)
|
593
598
|
end
|
594
599
|
end
|
595
600
|
|
@@ -741,6 +746,15 @@ private
|
|
741
746
|
SEV_LABEL[severity] || 'ANY'
|
742
747
|
end
|
743
748
|
|
749
|
+
# Guarantee the existence of this ivar even when subclasses don't call the superclass constructor.
|
750
|
+
def level_override
|
751
|
+
@level_override ||= {}
|
752
|
+
end
|
753
|
+
|
754
|
+
def level_key
|
755
|
+
Fiber.current
|
756
|
+
end
|
757
|
+
|
744
758
|
def format_message(severity, datetime, progname, msg)
|
745
759
|
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
746
760
|
end
|
data/logger.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.homepage = "https://github.com/ruby/logger"
|
16
16
|
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
17
17
|
|
18
|
-
spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
|
18
|
+
spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec", "BSDL", "COPYING"]
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.required_ruby_version = ">= 2.5.0"
|
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.6.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
- SHIBATA Hiroshi
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides a simple logging utility for outputting messages.
|
15
15
|
email:
|
@@ -19,6 +19,8 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- BSDL
|
23
|
+
- COPYING
|
22
24
|
- lib/logger.rb
|
23
25
|
- lib/logger/errors.rb
|
24
26
|
- lib/logger/formatter.rb
|
@@ -32,7 +34,7 @@ licenses:
|
|
32
34
|
- Ruby
|
33
35
|
- BSD-2-Clause
|
34
36
|
metadata: {}
|
35
|
-
post_install_message:
|
37
|
+
post_install_message:
|
36
38
|
rdoc_options: []
|
37
39
|
require_paths:
|
38
40
|
- lib
|
@@ -47,8 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
49
|
- !ruby/object:Gem::Version
|
48
50
|
version: '0'
|
49
51
|
requirements: []
|
50
|
-
rubygems_version: 3.5.
|
51
|
-
signing_key:
|
52
|
+
rubygems_version: 3.5.11
|
53
|
+
signing_key:
|
52
54
|
specification_version: 4
|
53
55
|
summary: Provides a simple logging utility for outputting messages.
|
54
56
|
test_files: []
|