logger 1.6.1 → 1.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/push_gem.yml +46 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +11 -0
- data/BSDL +22 -0
- data/COPYING +56 -0
- data/Gemfile +10 -0
- data/README.md +104 -0
- data/Rakefile +30 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/logger/log_device.rb +84 -56
- data/lib/logger/version.rb +1 -1
- data/lib/logger.rb +8 -4
- data/logger.gemspec +7 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 511e403d0d06ae6ca38d5757723c429618f5baf2e1a99e4ba838c29912cf1802
|
4
|
+
data.tar.gz: ba95f626decdf4a74fbf872032eefc8424edec77cdbd14cb25cc9aa0355c9b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01dbd6bb8fda92a1bdddc7a1d471e6a481168ef5f02e403e515650e99c3f08d8df2252d0e68a3767f0a60379d0081bfe07727af8e792af446bde934f9e2e3aca
|
7
|
+
data.tar.gz: 0ad9c452d95b51894574a88fff50c68afb7047f335e3f645b3df0584a41a8ef539212c9914428b5790822b9a848a7dbdd63bccdd76843fecaf8fb2f0bb474828
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: Publish gem to rubygems.org
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
push:
|
13
|
+
if: github.repository == 'ruby/logger'
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
environment:
|
17
|
+
name: rubygems.org
|
18
|
+
url: https://rubygems.org/gems/logger
|
19
|
+
|
20
|
+
permissions:
|
21
|
+
contents: write
|
22
|
+
id-token: write
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- name: Harden Runner
|
26
|
+
uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4
|
27
|
+
with:
|
28
|
+
egress-policy: audit
|
29
|
+
|
30
|
+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
|
31
|
+
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0
|
34
|
+
with:
|
35
|
+
bundler-cache: true
|
36
|
+
ruby-version: ruby
|
37
|
+
|
38
|
+
- name: Publish to RubyGems
|
39
|
+
uses: rubygems/release-gem@a25424ba2ba8b387abc8ef40807c2c85b96cbe32 # v1.1.1
|
40
|
+
|
41
|
+
- name: Create GitHub release
|
42
|
+
run: |
|
43
|
+
tag_name="$(git describe --tags --abbrev=0)"
|
44
|
+
gh release create "${tag_name}" --verify-tag --generate-notes
|
45
|
+
env:
|
46
|
+
GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_WORKFLOW_TOKEN }}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ruby-versions:
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
8
|
+
with:
|
9
|
+
engine: cruby-truffleruby
|
10
|
+
min_version: 2.5
|
11
|
+
|
12
|
+
test:
|
13
|
+
needs: ruby-versions
|
14
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
18
|
+
os: [ ubuntu-latest, macos-latest, windows-latest ]
|
19
|
+
exclude:
|
20
|
+
- ruby: 2.5
|
21
|
+
os: macos-latest
|
22
|
+
- ruby: truffleruby
|
23
|
+
os: windows-latest
|
24
|
+
- ruby: truffleruby-head
|
25
|
+
os: windows-latest
|
26
|
+
runs-on: ${{ matrix.os }}
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v4
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
- name: Install dependencies
|
34
|
+
run: bundle install
|
35
|
+
- name: Run test
|
36
|
+
run: rake test
|
data/.gitignore
ADDED
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/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Logger
|
2
|
+
|
3
|
+
Logger is a simple but powerful logging utility to output messages in your Ruby program.
|
4
|
+
|
5
|
+
Logger has the following features:
|
6
|
+
|
7
|
+
* Print messages to different levels such as `info` and `error`
|
8
|
+
* Auto-rolling of log files
|
9
|
+
* Setting the format of log messages
|
10
|
+
* Specifying a program name in conjunction with the message
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'logger'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install logger
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### Simple Example
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'logger'
|
34
|
+
|
35
|
+
# Create a Logger that prints to STDOUT
|
36
|
+
log = Logger.new(STDOUT)
|
37
|
+
log.debug("Created Logger")
|
38
|
+
|
39
|
+
log.info("Program finished")
|
40
|
+
|
41
|
+
# Create a Logger that prints to STDERR
|
42
|
+
error_log = Logger.new(STDERR)
|
43
|
+
error_log = error_log.error("fatal error")
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run the following to install dependencies.
|
49
|
+
|
50
|
+
```
|
51
|
+
$ bin/setup
|
52
|
+
```
|
53
|
+
|
54
|
+
Then, run the tests as:
|
55
|
+
|
56
|
+
```
|
57
|
+
$ rake test
|
58
|
+
```
|
59
|
+
|
60
|
+
To install this gem onto your local machine, run
|
61
|
+
|
62
|
+
```
|
63
|
+
$ rake install
|
64
|
+
```
|
65
|
+
|
66
|
+
To release a new version, update the version number in `lib/logger/version.rb`, and then run
|
67
|
+
|
68
|
+
```
|
69
|
+
$ rake release
|
70
|
+
```
|
71
|
+
|
72
|
+
which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
73
|
+
|
74
|
+
## Advanced Development
|
75
|
+
|
76
|
+
### Run tests of a specific file
|
77
|
+
|
78
|
+
```
|
79
|
+
$ ruby test/logger/test_logger.rb
|
80
|
+
```
|
81
|
+
|
82
|
+
### Run tests filtering test methods by a name
|
83
|
+
|
84
|
+
`--name` option is available as:
|
85
|
+
|
86
|
+
```
|
87
|
+
$ ruby test/logger/test_logger.rb --name test_lshift
|
88
|
+
```
|
89
|
+
|
90
|
+
### Publish documents to GitHub Pages
|
91
|
+
|
92
|
+
```
|
93
|
+
$ rake gh-pages
|
94
|
+
```
|
95
|
+
|
96
|
+
Then, git commit and push the generated HTMLs onto `gh-pages` branch.
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/logger.
|
101
|
+
|
102
|
+
## License
|
103
|
+
|
104
|
+
The gem is available as open source under the terms of the [BSD-2-Clause](BSDL).
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
require "rake/testtask"
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << "test/lib"
|
9
|
+
t.ruby_opts << "-rhelper"
|
10
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
require "rdoc/task"
|
14
|
+
RDoc::Task.new do |doc|
|
15
|
+
doc.main = "README.md"
|
16
|
+
doc.title = "Logger -- Ruby Standard Logger"
|
17
|
+
doc.rdoc_files = FileList.new %w[README.md lib BSDL COPYING]
|
18
|
+
doc.rdoc_dir = "html"
|
19
|
+
end
|
20
|
+
|
21
|
+
task "gh-pages" => :rdoc do
|
22
|
+
%x[git checkout gh-pages]
|
23
|
+
require "fileutils"
|
24
|
+
FileUtils.rm_rf "/tmp/html"
|
25
|
+
FileUtils.mv "html", "/tmp"
|
26
|
+
FileUtils.rm_rf "*"
|
27
|
+
FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
|
28
|
+
end
|
29
|
+
|
30
|
+
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "logger"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/logger/log_device.rb
CHANGED
@@ -30,29 +30,13 @@ class Logger
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def write(message)
|
33
|
-
|
33
|
+
handle_write_errors("writing") do
|
34
34
|
synchronize do
|
35
35
|
if @shift_age and @dev.respond_to?(:stat)
|
36
|
-
|
37
|
-
check_shift_log
|
38
|
-
rescue *@reraise_write_errors
|
39
|
-
raise
|
40
|
-
rescue
|
41
|
-
warn("log shifting failed. #{$!}")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
begin
|
45
|
-
@dev.write(message)
|
46
|
-
rescue *@reraise_write_errors
|
47
|
-
raise
|
48
|
-
rescue
|
49
|
-
warn("log writing failed. #{$!}")
|
36
|
+
handle_write_errors("shifting") {check_shift_log}
|
50
37
|
end
|
38
|
+
handle_write_errors("writing") {@dev.write(message)}
|
51
39
|
end
|
52
|
-
rescue *@reraise_write_errors
|
53
|
-
raise
|
54
|
-
rescue Exception => ignored
|
55
|
-
warn("log writing failed. #{ignored}")
|
56
40
|
end
|
57
41
|
end
|
58
42
|
|
@@ -83,6 +67,17 @@ class Logger
|
|
83
67
|
|
84
68
|
private
|
85
69
|
|
70
|
+
# :stopdoc:
|
71
|
+
|
72
|
+
MODE = File::WRONLY | File::APPEND
|
73
|
+
# TruffleRuby < 24.2 does not have File::SHARE_DELETE
|
74
|
+
if File.const_defined? :SHARE_DELETE
|
75
|
+
MODE_TO_OPEN = MODE | File::SHARE_DELETE | File::BINARY
|
76
|
+
else
|
77
|
+
MODE_TO_OPEN = MODE | File::BINARY
|
78
|
+
end
|
79
|
+
MODE_TO_CREATE = MODE_TO_OPEN | File::CREAT | File::EXCL
|
80
|
+
|
86
81
|
def set_dev(log)
|
87
82
|
if log.respond_to?(:write) and log.respond_to?(:close)
|
88
83
|
@dev = log
|
@@ -93,34 +88,62 @@ class Logger
|
|
93
88
|
end
|
94
89
|
else
|
95
90
|
@dev = open_logfile(log)
|
96
|
-
@dev.sync = true
|
97
|
-
@dev.binmode if @binmode
|
98
91
|
@filename = log
|
99
92
|
end
|
100
93
|
end
|
101
94
|
|
95
|
+
if MODE_TO_OPEN == MODE
|
96
|
+
def fixup_mode(dev, filename)
|
97
|
+
dev
|
98
|
+
end
|
99
|
+
else
|
100
|
+
def fixup_mode(dev, filename)
|
101
|
+
return dev if @binmode
|
102
|
+
filename = filename.respond_to?(:to_path) ? filename.to_path : filename
|
103
|
+
dev.autoclose = false
|
104
|
+
old_dev = dev
|
105
|
+
dev = File.new(dev.fileno, mode: MODE, path: filename)
|
106
|
+
old_dev.close
|
107
|
+
PathAttr.set_path(dev, filename) if defined?(PathAttr)
|
108
|
+
dev
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
102
112
|
def open_logfile(filename)
|
103
113
|
begin
|
104
|
-
File.open(filename,
|
114
|
+
dev = File.open(filename, MODE_TO_OPEN)
|
105
115
|
rescue Errno::ENOENT
|
106
116
|
create_logfile(filename)
|
117
|
+
else
|
118
|
+
dev = fixup_mode(dev, filename)
|
119
|
+
dev.sync = true
|
120
|
+
dev.binmode if @binmode
|
121
|
+
dev
|
107
122
|
end
|
108
123
|
end
|
109
124
|
|
110
125
|
def create_logfile(filename)
|
111
126
|
begin
|
112
|
-
logdev = File.open(filename,
|
127
|
+
logdev = File.open(filename, MODE_TO_CREATE)
|
113
128
|
logdev.flock(File::LOCK_EX)
|
129
|
+
logdev = fixup_mode(logdev, filename)
|
114
130
|
logdev.sync = true
|
115
131
|
logdev.binmode if @binmode
|
116
132
|
add_log_header(logdev)
|
117
133
|
logdev.flock(File::LOCK_UN)
|
134
|
+
logdev
|
118
135
|
rescue Errno::EEXIST
|
119
136
|
# file is created by another process
|
120
|
-
|
121
|
-
logdev.sync = true
|
137
|
+
open_logfile(filename)
|
122
138
|
end
|
123
|
-
|
139
|
+
end
|
140
|
+
|
141
|
+
def handle_write_errors(mesg)
|
142
|
+
yield
|
143
|
+
rescue *@reraise_write_errors
|
144
|
+
raise
|
145
|
+
rescue
|
146
|
+
warn("log #{mesg} failed. #{$!}")
|
124
147
|
end
|
125
148
|
|
126
149
|
def add_log_header(file)
|
@@ -144,40 +167,33 @@ class Logger
|
|
144
167
|
end
|
145
168
|
end
|
146
169
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
begin
|
156
|
-
File.open(@filename, File::WRONLY | File::APPEND) do |lock|
|
157
|
-
lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
|
158
|
-
if File.identical?(@filename, lock) and File.identical?(lock, @dev)
|
159
|
-
yield # log shifting
|
160
|
-
else
|
161
|
-
# log shifted by another process (i-node before locking and i-node after locking are different)
|
162
|
-
@dev.close rescue nil
|
163
|
-
@dev = open_logfile(@filename)
|
164
|
-
@dev.sync = true
|
165
|
-
end
|
166
|
-
end
|
167
|
-
rescue Errno::ENOENT
|
168
|
-
# @filename file would not exist right after #rename and before #create_logfile
|
169
|
-
if retry_limit <= 0
|
170
|
-
warn("log rotation inter-process lock failed. #{$!}")
|
170
|
+
def lock_shift_log
|
171
|
+
retry_limit = 8
|
172
|
+
retry_sleep = 0.1
|
173
|
+
begin
|
174
|
+
File.open(@filename, MODE_TO_OPEN) do |lock|
|
175
|
+
lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
|
176
|
+
if File.identical?(@filename, lock) and File.identical?(lock, @dev)
|
177
|
+
yield # log shifting
|
171
178
|
else
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
retry
|
179
|
+
# log shifted by another process (i-node before locking and i-node after locking are different)
|
180
|
+
@dev.close rescue nil
|
181
|
+
@dev = open_logfile(@filename)
|
176
182
|
end
|
177
183
|
end
|
178
|
-
rescue
|
179
|
-
|
184
|
+
rescue Errno::ENOENT
|
185
|
+
# @filename file would not exist right after #rename and before #create_logfile
|
186
|
+
if retry_limit <= 0
|
187
|
+
warn("log rotation inter-process lock failed. #{$!}")
|
188
|
+
else
|
189
|
+
sleep retry_sleep
|
190
|
+
retry_limit -= 1
|
191
|
+
retry_sleep *= 2
|
192
|
+
retry
|
193
|
+
end
|
180
194
|
end
|
195
|
+
rescue
|
196
|
+
warn("log rotation inter-process lock failed. #{$!}")
|
181
197
|
end
|
182
198
|
|
183
199
|
def shift_log_age
|
@@ -212,3 +228,15 @@ class Logger
|
|
212
228
|
end
|
213
229
|
end
|
214
230
|
end
|
231
|
+
|
232
|
+
File.open(__FILE__) do |f|
|
233
|
+
File.new(f.fileno, autoclose: false, path: "").path
|
234
|
+
rescue IOError
|
235
|
+
module PathAttr # :nodoc:
|
236
|
+
attr_reader :path
|
237
|
+
|
238
|
+
def self.set_path(file, path)
|
239
|
+
file.extend(self).instance_variable_set(:@path, path)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
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
|
-
level_override[
|
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, level_override[
|
409
|
+
prev, level_override[level_key] = level, Severity.coerce(severity)
|
410
410
|
begin
|
411
411
|
yield
|
412
412
|
ensure
|
413
413
|
if prev
|
414
|
-
level_override[
|
414
|
+
level_override[level_key] = prev
|
415
415
|
else
|
416
|
-
level_override.delete(
|
416
|
+
level_override.delete(level_key)
|
417
417
|
end
|
418
418
|
end
|
419
419
|
end
|
@@ -751,6 +751,10 @@ private
|
|
751
751
|
@level_override ||= {}
|
752
752
|
end
|
753
753
|
|
754
|
+
def level_key
|
755
|
+
Fiber.current
|
756
|
+
end
|
757
|
+
|
754
758
|
def format_message(severity, datetime, progname, msg)
|
755
759
|
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
756
760
|
end
|
data/logger.gemspec
CHANGED
@@ -15,8 +15,14 @@ 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
|
-
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
19
23
|
spec.require_paths = ["lib"]
|
20
24
|
|
21
25
|
spec.required_ruby_version = ">= 2.5.0"
|
26
|
+
|
27
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/releases"
|
22
28
|
end
|
metadata
CHANGED
@@ -1,14 +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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
- SHIBATA Hiroshi
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Provides a simple logging utility for outputting messages.
|
14
15
|
email:
|
@@ -18,6 +19,17 @@ executables: []
|
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files: []
|
20
21
|
files:
|
22
|
+
- ".github/dependabot.yml"
|
23
|
+
- ".github/workflows/push_gem.yml"
|
24
|
+
- ".github/workflows/test.yml"
|
25
|
+
- ".gitignore"
|
26
|
+
- BSDL
|
27
|
+
- COPYING
|
28
|
+
- Gemfile
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
31
|
+
- bin/console
|
32
|
+
- bin/setup
|
21
33
|
- lib/logger.rb
|
22
34
|
- lib/logger/errors.rb
|
23
35
|
- lib/logger/formatter.rb
|
@@ -30,7 +42,9 @@ homepage: https://github.com/ruby/logger
|
|
30
42
|
licenses:
|
31
43
|
- Ruby
|
32
44
|
- BSD-2-Clause
|
33
|
-
metadata:
|
45
|
+
metadata:
|
46
|
+
changelog_uri: https://github.com/ruby/logger/releases
|
47
|
+
post_install_message:
|
34
48
|
rdoc_options: []
|
35
49
|
require_paths:
|
36
50
|
- lib
|
@@ -45,7 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: '0'
|
47
61
|
requirements: []
|
48
|
-
rubygems_version: 3.
|
62
|
+
rubygems_version: 3.5.11
|
63
|
+
signing_key:
|
49
64
|
specification_version: 4
|
50
65
|
summary: Provides a simple logging utility for outputting messages.
|
51
66
|
test_files: []
|