logger 1.4.0 → 1.4.4
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/lib/logger/errors.rb +9 -0
- data/lib/logger/formatter.rb +36 -0
- data/lib/logger/log_device.rb +205 -0
- data/lib/logger/period.rb +47 -0
- data/lib/logger/severity.rb +19 -0
- data/lib/logger/version.rb +5 -0
- data/lib/logger.rb +20 -18
- data/logger.gemspec +4 -6
- metadata +18 -15
- data/Gemfile +0 -5
- data/LICENSE.txt +0 -22
- data/README.md +0 -104
- data/Rakefile +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ff5c7f2a189b07730b1fbe6287938cf7501889ee62bd89d8de6d02902f1bee
|
4
|
+
data.tar.gz: 62343e3ea1b0dbd6cdb94ff67721f1f86e54876bd6cd0265b112181d60fd1125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302bbc40320bd744a40924ce6837499d2d9460ebab7745805352cb86d1348737a350bcb94918474cc0cf517b04b6b374eddcfc6a9d142d92943d99ec746df335
|
7
|
+
data.tar.gz: c4d057679ca2aed3e4e57424eacb0167ebb34fcb135bb7b9961a7f2e4b0bfdb33a6f902cd5255acaee7d04adb10d9d5e7035a3784aa0b3e9bc19b5fdd2d528e7
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Logger
|
4
|
+
# Default formatter for log messages.
|
5
|
+
class Formatter
|
6
|
+
Format = "%s, [%s#%d] %5s -- %s: %s\n"
|
7
|
+
|
8
|
+
attr_accessor :datetime_format
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@datetime_format = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def call(severity, time, progname, msg)
|
15
|
+
Format % [severity[0..0], format_datetime(time), Process.pid, severity, progname,
|
16
|
+
msg2str(msg)]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def format_datetime(time)
|
22
|
+
time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ")
|
23
|
+
end
|
24
|
+
|
25
|
+
def msg2str(msg)
|
26
|
+
case msg
|
27
|
+
when ::String
|
28
|
+
msg
|
29
|
+
when ::Exception
|
30
|
+
"#{ msg.message } (#{ msg.class })\n#{ msg.backtrace.join("\n") if msg.backtrace }"
|
31
|
+
else
|
32
|
+
msg.inspect
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'period'
|
4
|
+
|
5
|
+
class Logger
|
6
|
+
# Device used for logging messages.
|
7
|
+
class LogDevice
|
8
|
+
include Period
|
9
|
+
|
10
|
+
attr_reader :dev
|
11
|
+
attr_reader :filename
|
12
|
+
include MonitorMixin
|
13
|
+
|
14
|
+
def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil, binmode: false)
|
15
|
+
@dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
|
16
|
+
@binmode = binmode
|
17
|
+
mon_initialize
|
18
|
+
set_dev(log)
|
19
|
+
if @filename
|
20
|
+
@shift_age = shift_age || 7
|
21
|
+
@shift_size = shift_size || 1048576
|
22
|
+
@shift_period_suffix = shift_period_suffix || '%Y%m%d'
|
23
|
+
|
24
|
+
unless @shift_age.is_a?(Integer)
|
25
|
+
base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now
|
26
|
+
@next_rotate_time = next_rotate_time(base_time, @shift_age)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def write(message)
|
32
|
+
begin
|
33
|
+
synchronize do
|
34
|
+
if @shift_age and @dev.respond_to?(:stat)
|
35
|
+
begin
|
36
|
+
check_shift_log
|
37
|
+
rescue
|
38
|
+
warn("log shifting failed. #{$!}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
begin
|
42
|
+
@dev.write(message)
|
43
|
+
rescue
|
44
|
+
warn("log writing failed. #{$!}")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue Exception => ignored
|
48
|
+
warn("log writing failed. #{ignored}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def close
|
53
|
+
begin
|
54
|
+
synchronize do
|
55
|
+
@dev.close rescue nil
|
56
|
+
end
|
57
|
+
rescue Exception
|
58
|
+
@dev.close rescue nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def reopen(log = nil)
|
63
|
+
# reopen the same filename if no argument, do nothing for IO
|
64
|
+
log ||= @filename if @filename
|
65
|
+
if log
|
66
|
+
synchronize do
|
67
|
+
if @filename and @dev
|
68
|
+
@dev.close rescue nil # close only file opened by Logger
|
69
|
+
@filename = nil
|
70
|
+
end
|
71
|
+
set_dev(log)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def set_dev(log)
|
80
|
+
if log.respond_to?(:write) and log.respond_to?(:close)
|
81
|
+
@dev = log
|
82
|
+
if log.respond_to?(:path)
|
83
|
+
@filename = log.path
|
84
|
+
end
|
85
|
+
else
|
86
|
+
@dev = open_logfile(log)
|
87
|
+
@dev.sync = true
|
88
|
+
@dev.binmode if @binmode
|
89
|
+
@filename = log
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def open_logfile(filename)
|
94
|
+
begin
|
95
|
+
File.open(filename, (File::WRONLY | File::APPEND))
|
96
|
+
rescue Errno::ENOENT
|
97
|
+
create_logfile(filename)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def create_logfile(filename)
|
102
|
+
begin
|
103
|
+
logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
|
104
|
+
logdev.flock(File::LOCK_EX)
|
105
|
+
logdev.sync = true
|
106
|
+
logdev.binmode if @binmode
|
107
|
+
add_log_header(logdev)
|
108
|
+
logdev.flock(File::LOCK_UN)
|
109
|
+
rescue Errno::EEXIST
|
110
|
+
# file is created by another process
|
111
|
+
logdev = open_logfile(filename)
|
112
|
+
logdev.sync = true
|
113
|
+
end
|
114
|
+
logdev
|
115
|
+
end
|
116
|
+
|
117
|
+
def add_log_header(file)
|
118
|
+
file.write(
|
119
|
+
"# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
|
120
|
+
) if file.size == 0
|
121
|
+
end
|
122
|
+
|
123
|
+
def check_shift_log
|
124
|
+
if @shift_age.is_a?(Integer)
|
125
|
+
# Note: always returns false if '0'.
|
126
|
+
if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
|
127
|
+
lock_shift_log { shift_log_age }
|
128
|
+
end
|
129
|
+
else
|
130
|
+
now = Time.now
|
131
|
+
if now >= @next_rotate_time
|
132
|
+
@next_rotate_time = next_rotate_time(now, @shift_age)
|
133
|
+
lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM
|
139
|
+
def lock_shift_log
|
140
|
+
yield
|
141
|
+
end
|
142
|
+
else
|
143
|
+
def lock_shift_log
|
144
|
+
retry_limit = 8
|
145
|
+
retry_sleep = 0.1
|
146
|
+
begin
|
147
|
+
File.open(@filename, File::WRONLY | File::APPEND) do |lock|
|
148
|
+
lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
|
149
|
+
if File.identical?(@filename, lock) and File.identical?(lock, @dev)
|
150
|
+
yield # log shifting
|
151
|
+
else
|
152
|
+
# log shifted by another process (i-node before locking and i-node after locking are different)
|
153
|
+
@dev.close rescue nil
|
154
|
+
@dev = open_logfile(@filename)
|
155
|
+
@dev.sync = true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
rescue Errno::ENOENT
|
159
|
+
# @filename file would not exist right after #rename and before #create_logfile
|
160
|
+
if retry_limit <= 0
|
161
|
+
warn("log rotation inter-process lock failed. #{$!}")
|
162
|
+
else
|
163
|
+
sleep retry_sleep
|
164
|
+
retry_limit -= 1
|
165
|
+
retry_sleep *= 2
|
166
|
+
retry
|
167
|
+
end
|
168
|
+
end
|
169
|
+
rescue
|
170
|
+
warn("log rotation inter-process lock failed. #{$!}")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def shift_log_age
|
175
|
+
(@shift_age-3).downto(0) do |i|
|
176
|
+
if FileTest.exist?("#{@filename}.#{i}")
|
177
|
+
File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
@dev.close rescue nil
|
181
|
+
File.rename("#{@filename}", "#{@filename}.0")
|
182
|
+
@dev = create_logfile(@filename)
|
183
|
+
return true
|
184
|
+
end
|
185
|
+
|
186
|
+
def shift_log_period(period_end)
|
187
|
+
suffix = period_end.strftime(@shift_period_suffix)
|
188
|
+
age_file = "#{@filename}.#{suffix}"
|
189
|
+
if FileTest.exist?(age_file)
|
190
|
+
# try to avoid filename crash caused by Timestamp change.
|
191
|
+
idx = 0
|
192
|
+
# .99 can be overridden; avoid too much file search with 'loop do'
|
193
|
+
while idx < 100
|
194
|
+
idx += 1
|
195
|
+
age_file = "#{@filename}.#{suffix}.#{idx}"
|
196
|
+
break unless FileTest.exist?(age_file)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
@dev.close rescue nil
|
200
|
+
File.rename("#{@filename}", age_file)
|
201
|
+
@dev = create_logfile(@filename)
|
202
|
+
return true
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Logger
|
4
|
+
module Period
|
5
|
+
module_function
|
6
|
+
|
7
|
+
SiD = 24 * 60 * 60
|
8
|
+
|
9
|
+
def next_rotate_time(now, shift_age)
|
10
|
+
case shift_age
|
11
|
+
when 'daily'
|
12
|
+
t = Time.mktime(now.year, now.month, now.mday) + SiD
|
13
|
+
when 'weekly'
|
14
|
+
t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
|
15
|
+
when 'monthly'
|
16
|
+
t = Time.mktime(now.year, now.month, 1) + SiD * 32
|
17
|
+
return Time.mktime(t.year, t.month, 1)
|
18
|
+
when 'now', 'everytime'
|
19
|
+
return now
|
20
|
+
else
|
21
|
+
raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
|
22
|
+
end
|
23
|
+
if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
|
24
|
+
hour = t.hour
|
25
|
+
t = Time.mktime(t.year, t.month, t.mday)
|
26
|
+
t += SiD if hour > 12
|
27
|
+
end
|
28
|
+
t
|
29
|
+
end
|
30
|
+
|
31
|
+
def previous_period_end(now, shift_age)
|
32
|
+
case shift_age
|
33
|
+
when 'daily'
|
34
|
+
t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
|
35
|
+
when 'weekly'
|
36
|
+
t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
|
37
|
+
when 'monthly'
|
38
|
+
t = Time.mktime(now.year, now.month, 1) - SiD / 2
|
39
|
+
when 'now', 'everytime'
|
40
|
+
return now
|
41
|
+
else
|
42
|
+
raise ArgumentError, "invalid :shift_age #{shift_age.inspect}, should be daily, weekly, monthly, or everytime"
|
43
|
+
end
|
44
|
+
Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Logger
|
4
|
+
# Logging severity.
|
5
|
+
module Severity
|
6
|
+
# Low-level information, mostly for developers.
|
7
|
+
DEBUG = 0
|
8
|
+
# Generic (useful) information about system operation.
|
9
|
+
INFO = 1
|
10
|
+
# A warning.
|
11
|
+
WARN = 2
|
12
|
+
# A handleable error condition.
|
13
|
+
ERROR = 3
|
14
|
+
# An unhandleable error that results in a program crash.
|
15
|
+
FATAL = 4
|
16
|
+
# An unknown message that should always be logged.
|
17
|
+
UNKNOWN = 5
|
18
|
+
end
|
19
|
+
end
|
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
|
-
spec.files =
|
19
|
-
spec.bindir = "exe"
|
20
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
|
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.
|
4
|
+
version: 1.4.4
|
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-10-19 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
|
@@ -75,17 +75,20 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- Gemfile
|
79
|
-
- LICENSE.txt
|
80
|
-
- README.md
|
81
|
-
- Rakefile
|
82
78
|
- lib/logger.rb
|
79
|
+
- lib/logger/errors.rb
|
80
|
+
- lib/logger/formatter.rb
|
81
|
+
- lib/logger/log_device.rb
|
82
|
+
- lib/logger/period.rb
|
83
|
+
- lib/logger/severity.rb
|
84
|
+
- lib/logger/version.rb
|
83
85
|
- logger.gemspec
|
84
86
|
homepage: https://github.com/ruby/logger
|
85
87
|
licenses:
|
88
|
+
- Ruby
|
86
89
|
- BSD-2-Clause
|
87
90
|
metadata: {}
|
88
|
-
post_install_message:
|
91
|
+
post_install_message:
|
89
92
|
rdoc_options: []
|
90
93
|
require_paths:
|
91
94
|
- lib
|
@@ -100,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
103
|
- !ruby/object:Gem::Version
|
101
104
|
version: '0'
|
102
105
|
requirements: []
|
103
|
-
rubygems_version: 3.0.
|
104
|
-
signing_key:
|
106
|
+
rubygems_version: 3.3.0.dev
|
107
|
+
signing_key:
|
105
108
|
specification_version: 4
|
106
109
|
summary: Provides a simple logging utility for outputting messages.
|
107
110
|
test_files: []
|
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
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/README.md
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
# Logger
|
2
|
-
|
3
|
-
[](https://travis-ci.com/ruby/logger)
|
4
|
-
|
5
|
-
Logger is a simple but powerful logging utility to output messages in your Ruby program.
|
6
|
-
|
7
|
-
Logger has the following features:
|
8
|
-
|
9
|
-
* Print messages to different levels such as `info` and `error`
|
10
|
-
* Auto-rolling of log files
|
11
|
-
* Setting the format of log messages
|
12
|
-
* Specifying a program name in conjunction with the message
|
13
|
-
|
14
|
-
## Installation
|
15
|
-
|
16
|
-
Add this line to your application's Gemfile:
|
17
|
-
|
18
|
-
```ruby
|
19
|
-
gem 'logger'
|
20
|
-
```
|
21
|
-
|
22
|
-
And then execute:
|
23
|
-
|
24
|
-
$ bundle
|
25
|
-
|
26
|
-
Or install it yourself as:
|
27
|
-
|
28
|
-
$ gem install logger
|
29
|
-
|
30
|
-
## Usage
|
31
|
-
|
32
|
-
### Simple Example
|
33
|
-
|
34
|
-
require 'logger'
|
35
|
-
|
36
|
-
# Create a Logger that prints to STDOUT
|
37
|
-
log = Logger.new(STDOUT)
|
38
|
-
log.debug("Created Logger")
|
39
|
-
|
40
|
-
log.info("Program finished")
|
41
|
-
|
42
|
-
# Create a Logger that prints to STDERR
|
43
|
-
error_log = Logger.new(STDERR)
|
44
|
-
error_log = Logger.error("fatal error")
|
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](LICENSE.txt).
|
data/Rakefile
DELETED
@@ -1,28 +0,0 @@
|
|
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.test_files = FileList["test/**/test_*.rb"]
|
9
|
-
end
|
10
|
-
|
11
|
-
require "rdoc/task"
|
12
|
-
RDoc::Task.new do |doc|
|
13
|
-
doc.main = "README.md"
|
14
|
-
doc.title = "Logger -- Ruby Standard Logger"
|
15
|
-
doc.rdoc_files = FileList.new %w[README.md lib LICENSE.txt]
|
16
|
-
doc.rdoc_dir = "html"
|
17
|
-
end
|
18
|
-
|
19
|
-
task "gh-pages" => :rdoc do
|
20
|
-
%x[git checkout gh-pages]
|
21
|
-
require "fileutils"
|
22
|
-
FileUtils.rm_rf "/tmp/html"
|
23
|
-
FileUtils.mv "html", "/tmp"
|
24
|
-
FileUtils.rm_rf "*"
|
25
|
-
FileUtils.cp_r Dir.glob("/tmp/html/*"), "."
|
26
|
-
end
|
27
|
-
|
28
|
-
task :default => :test
|