logger 1.3.0 → 1.4.0
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/Gemfile +0 -1
- data/README.md +70 -5
- data/Rakefile +22 -4
- data/lib/logger.rb +31 -298
- data/logger.gemspec +11 -9
- metadata +29 -18
- data/.gitignore +0 -8
- data/.travis.yml +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ac30b81e7461bb8da11d63f68d4981b0f058960d6001319c8709c98b05b1dfa
|
4
|
+
data.tar.gz: 25dfc74c49ea696330c6e2c435a27a0b6933ecd65cf4ed9ea2ede8accde35606
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d724998e973037c4c5baaae8c8edc965129533a72f70b0551cfed8c871e27d6ec11e780636b329fb9ba9636e22da0cb0cfe0e76bf0fe73fe6cbbdc575068c0b
|
7
|
+
data.tar.gz: aaf0393b43f86dc1cada4f57e5faf64159f3d1cf52a93e97077b64721bd6287aaea7f55a7377ecf74689ed68ecda65c58440b27fbf1404f7ffd087fd80f0381a
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
# Logger
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.com/ruby/logger)
|
4
4
|
|
5
|
-
|
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
|
6
13
|
|
7
14
|
## Installation
|
8
15
|
|
@@ -22,13 +29,71 @@ Or install it yourself as:
|
|
22
29
|
|
23
30
|
## Usage
|
24
31
|
|
25
|
-
|
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")
|
26
45
|
|
27
46
|
## Development
|
28
47
|
|
29
|
-
After checking out the repo, run
|
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
|
+
```
|
30
95
|
|
31
|
-
|
96
|
+
Then, git commit and push the generated HTMLs onto `gh-pages` branch.
|
32
97
|
|
33
98
|
## Contributing
|
34
99
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,28 @@
|
|
1
|
-
|
2
|
-
require "
|
1
|
+
begin
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
rescue LoadError
|
4
|
+
end
|
3
5
|
|
6
|
+
require "rake/testtask"
|
4
7
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib" << "test/lib"
|
7
8
|
t.test_files = FileList["test/**/test_*.rb"]
|
8
9
|
end
|
9
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
|
+
|
10
28
|
task :default => :test
|
data/lib/logger.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
# logger.rb - simple logging utility
|
3
3
|
# Copyright (C) 2000-2003, 2005, 2008, 2011 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
4
4
|
#
|
@@ -12,6 +12,12 @@
|
|
12
12
|
|
13
13
|
require 'monitor'
|
14
14
|
|
15
|
+
require_relative 'logger/version'
|
16
|
+
require_relative 'logger/formatter'
|
17
|
+
require_relative 'logger/log_device'
|
18
|
+
require_relative 'logger/severity'
|
19
|
+
require_relative 'logger/errors'
|
20
|
+
|
15
21
|
# == Description
|
16
22
|
#
|
17
23
|
# The Logger class provides a simple but sophisticated logging utility that
|
@@ -224,7 +230,6 @@ require 'monitor'
|
|
224
230
|
# })
|
225
231
|
#
|
226
232
|
class Logger
|
227
|
-
VERSION = "1.3.0"
|
228
233
|
_, name, rev = %w$Id$
|
229
234
|
if name
|
230
235
|
name = name.chomp(",v")
|
@@ -232,29 +237,8 @@ class Logger
|
|
232
237
|
name = File.basename(__FILE__)
|
233
238
|
end
|
234
239
|
rev ||= "v#{VERSION}"
|
235
|
-
ProgName = "#{name}/#{rev}"
|
240
|
+
ProgName = "#{name}/#{rev}"
|
236
241
|
|
237
|
-
class Error < RuntimeError # :nodoc:
|
238
|
-
end
|
239
|
-
# not used after 1.2.7. just for compat.
|
240
|
-
class ShiftingError < Error # :nodoc:
|
241
|
-
end
|
242
|
-
|
243
|
-
# Logging severity.
|
244
|
-
module Severity
|
245
|
-
# Low-level information, mostly for developers.
|
246
|
-
DEBUG = 0
|
247
|
-
# Generic (useful) information about system operation.
|
248
|
-
INFO = 1
|
249
|
-
# A warning.
|
250
|
-
WARN = 2
|
251
|
-
# A handleable error condition.
|
252
|
-
ERROR = 3
|
253
|
-
# An unhandleable error that results in a program crash.
|
254
|
-
FATAL = 4
|
255
|
-
# An unknown message that should always be logged.
|
256
|
-
UNKNOWN = 5
|
257
|
-
end
|
258
242
|
include Severity
|
259
243
|
|
260
244
|
# Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
|
@@ -322,22 +306,37 @@ class Logger
|
|
322
306
|
# +DEBUG+ messages.
|
323
307
|
def debug?; @level <= DEBUG; end
|
324
308
|
|
309
|
+
# Sets the severity to DEBUG.
|
310
|
+
def debug!; self.level = DEBUG; end
|
311
|
+
|
325
312
|
# Returns +true+ iff the current severity level allows for the printing of
|
326
313
|
# +INFO+ messages.
|
327
314
|
def info?; @level <= INFO; end
|
328
315
|
|
316
|
+
# Sets the severity to INFO.
|
317
|
+
def info!; self.level = INFO; end
|
318
|
+
|
329
319
|
# Returns +true+ iff the current severity level allows for the printing of
|
330
320
|
# +WARN+ messages.
|
331
321
|
def warn?; @level <= WARN; end
|
332
322
|
|
323
|
+
# Sets the severity to WARN.
|
324
|
+
def warn!; self.level = WARN; end
|
325
|
+
|
333
326
|
# Returns +true+ iff the current severity level allows for the printing of
|
334
327
|
# +ERROR+ messages.
|
335
328
|
def error?; @level <= ERROR; end
|
336
329
|
|
330
|
+
# Sets the severity to ERROR.
|
331
|
+
def error!; self.level = ERROR; end
|
332
|
+
|
337
333
|
# Returns +true+ iff the current severity level allows for the printing of
|
338
334
|
# +FATAL+ messages.
|
339
335
|
def fatal?; @level <= FATAL; end
|
340
336
|
|
337
|
+
# Sets the severity to FATAL.
|
338
|
+
def fatal!; self.level = FATAL; end
|
339
|
+
|
341
340
|
#
|
342
341
|
# :call-seq:
|
343
342
|
# Logger.new(logdev, shift_age = 0, shift_size = 1048576)
|
@@ -366,6 +365,8 @@ class Logger
|
|
366
365
|
# Logging formatter. Default values is an instance of Logger::Formatter.
|
367
366
|
# +datetime_format+::
|
368
367
|
# Date and time format. Default value is '%Y-%m-%d %H:%M:%S'.
|
368
|
+
# +binmode+::
|
369
|
+
# Use binary mode on the log device. Default value is false.
|
369
370
|
# +shift_period_suffix+::
|
370
371
|
# The log file suffix format for +daily+, +weekly+ or +monthly+ rotation.
|
371
372
|
# Default is '%Y%m%d'.
|
@@ -376,7 +377,7 @@ class Logger
|
|
376
377
|
#
|
377
378
|
def initialize(logdev, shift_age = 0, shift_size = 1048576, level: DEBUG,
|
378
379
|
progname: nil, formatter: nil, datetime_format: nil,
|
379
|
-
shift_period_suffix: '%Y%m%d')
|
380
|
+
binmode: false, shift_period_suffix: '%Y%m%d')
|
380
381
|
self.level = level
|
381
382
|
self.progname = progname
|
382
383
|
@default_formatter = Formatter.new
|
@@ -384,9 +385,10 @@ class Logger
|
|
384
385
|
self.formatter = formatter
|
385
386
|
@logdev = nil
|
386
387
|
if logdev
|
387
|
-
@logdev = LogDevice.new(logdev, :
|
388
|
-
:
|
389
|
-
:
|
388
|
+
@logdev = LogDevice.new(logdev, shift_age: shift_age,
|
389
|
+
shift_size: shift_size,
|
390
|
+
shift_period_suffix: shift_period_suffix,
|
391
|
+
binmode: binmode)
|
390
392
|
end
|
391
393
|
end
|
392
394
|
|
@@ -572,7 +574,7 @@ class Logger
|
|
572
574
|
private
|
573
575
|
|
574
576
|
# Severity label for logging (max 5 chars).
|
575
|
-
SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY).
|
577
|
+
SEV_LABEL = %w(DEBUG INFO WARN ERROR FATAL ANY).freeze
|
576
578
|
|
577
579
|
def format_severity(severity)
|
578
580
|
SEV_LABEL[severity] || 'ANY'
|
@@ -581,273 +583,4 @@ private
|
|
581
583
|
def format_message(severity, datetime, progname, msg)
|
582
584
|
(@formatter || @default_formatter).call(severity, datetime, progname, msg)
|
583
585
|
end
|
584
|
-
|
585
|
-
|
586
|
-
# Default formatter for log messages.
|
587
|
-
class Formatter
|
588
|
-
Format = "%s, [%s#%d] %5s -- %s: %s\n".freeze
|
589
|
-
|
590
|
-
attr_accessor :datetime_format
|
591
|
-
|
592
|
-
def initialize
|
593
|
-
@datetime_format = nil
|
594
|
-
end
|
595
|
-
|
596
|
-
def call(severity, time, progname, msg)
|
597
|
-
Format % [severity[0..0], format_datetime(time), $$, severity, progname,
|
598
|
-
msg2str(msg)]
|
599
|
-
end
|
600
|
-
|
601
|
-
private
|
602
|
-
|
603
|
-
def format_datetime(time)
|
604
|
-
time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze)
|
605
|
-
end
|
606
|
-
|
607
|
-
def msg2str(msg)
|
608
|
-
case msg
|
609
|
-
when ::String
|
610
|
-
msg
|
611
|
-
when ::Exception
|
612
|
-
"#{ msg.message } (#{ msg.class })\n" <<
|
613
|
-
(msg.backtrace || []).join("\n")
|
614
|
-
else
|
615
|
-
msg.inspect
|
616
|
-
end
|
617
|
-
end
|
618
|
-
end
|
619
|
-
|
620
|
-
module Period
|
621
|
-
module_function
|
622
|
-
|
623
|
-
SiD = 24 * 60 * 60
|
624
|
-
|
625
|
-
def next_rotate_time(now, shift_age)
|
626
|
-
case shift_age
|
627
|
-
when 'daily'
|
628
|
-
t = Time.mktime(now.year, now.month, now.mday) + SiD
|
629
|
-
when 'weekly'
|
630
|
-
t = Time.mktime(now.year, now.month, now.mday) + SiD * (7 - now.wday)
|
631
|
-
when 'monthly'
|
632
|
-
t = Time.mktime(now.year, now.month, 1) + SiD * 32
|
633
|
-
return Time.mktime(t.year, t.month, 1)
|
634
|
-
else
|
635
|
-
return now
|
636
|
-
end
|
637
|
-
if t.hour.nonzero? or t.min.nonzero? or t.sec.nonzero?
|
638
|
-
hour = t.hour
|
639
|
-
t = Time.mktime(t.year, t.month, t.mday)
|
640
|
-
t += SiD if hour > 12
|
641
|
-
end
|
642
|
-
t
|
643
|
-
end
|
644
|
-
|
645
|
-
def previous_period_end(now, shift_age)
|
646
|
-
case shift_age
|
647
|
-
when 'daily'
|
648
|
-
t = Time.mktime(now.year, now.month, now.mday) - SiD / 2
|
649
|
-
when 'weekly'
|
650
|
-
t = Time.mktime(now.year, now.month, now.mday) - (SiD * now.wday + SiD / 2)
|
651
|
-
when 'monthly'
|
652
|
-
t = Time.mktime(now.year, now.month, 1) - SiD / 2
|
653
|
-
else
|
654
|
-
return now
|
655
|
-
end
|
656
|
-
Time.mktime(t.year, t.month, t.mday, 23, 59, 59)
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
# Device used for logging messages.
|
661
|
-
class LogDevice
|
662
|
-
include Period
|
663
|
-
|
664
|
-
attr_reader :dev
|
665
|
-
attr_reader :filename
|
666
|
-
include MonitorMixin
|
667
|
-
|
668
|
-
def initialize(log = nil, shift_age: nil, shift_size: nil, shift_period_suffix: nil)
|
669
|
-
@dev = @filename = @shift_age = @shift_size = @shift_period_suffix = nil
|
670
|
-
mon_initialize
|
671
|
-
set_dev(log)
|
672
|
-
if @filename
|
673
|
-
@shift_age = shift_age || 7
|
674
|
-
@shift_size = shift_size || 1048576
|
675
|
-
@shift_period_suffix = shift_period_suffix || '%Y%m%d'
|
676
|
-
|
677
|
-
unless @shift_age.is_a?(Integer)
|
678
|
-
base_time = @dev.respond_to?(:stat) ? @dev.stat.mtime : Time.now
|
679
|
-
@next_rotate_time = next_rotate_time(base_time, @shift_age)
|
680
|
-
end
|
681
|
-
end
|
682
|
-
end
|
683
|
-
|
684
|
-
def write(message)
|
685
|
-
begin
|
686
|
-
synchronize do
|
687
|
-
if @shift_age and @dev.respond_to?(:stat)
|
688
|
-
begin
|
689
|
-
check_shift_log
|
690
|
-
rescue
|
691
|
-
warn("log shifting failed. #{$!}")
|
692
|
-
end
|
693
|
-
end
|
694
|
-
begin
|
695
|
-
@dev.write(message)
|
696
|
-
rescue
|
697
|
-
warn("log writing failed. #{$!}")
|
698
|
-
end
|
699
|
-
end
|
700
|
-
rescue Exception => ignored
|
701
|
-
warn("log writing failed. #{ignored}")
|
702
|
-
end
|
703
|
-
end
|
704
|
-
|
705
|
-
def close
|
706
|
-
begin
|
707
|
-
synchronize do
|
708
|
-
@dev.close rescue nil
|
709
|
-
end
|
710
|
-
rescue Exception
|
711
|
-
@dev.close rescue nil
|
712
|
-
end
|
713
|
-
end
|
714
|
-
|
715
|
-
def reopen(log = nil)
|
716
|
-
# reopen the same filename if no argument, do nothing for IO
|
717
|
-
log ||= @filename if @filename
|
718
|
-
if log
|
719
|
-
synchronize do
|
720
|
-
if @filename and @dev
|
721
|
-
@dev.close rescue nil # close only file opened by Logger
|
722
|
-
@filename = nil
|
723
|
-
end
|
724
|
-
set_dev(log)
|
725
|
-
end
|
726
|
-
end
|
727
|
-
self
|
728
|
-
end
|
729
|
-
|
730
|
-
private
|
731
|
-
|
732
|
-
def set_dev(log)
|
733
|
-
if log.respond_to?(:write) and log.respond_to?(:close)
|
734
|
-
@dev = log
|
735
|
-
else
|
736
|
-
@dev = open_logfile(log)
|
737
|
-
@dev.sync = true
|
738
|
-
@filename = log
|
739
|
-
end
|
740
|
-
end
|
741
|
-
|
742
|
-
def open_logfile(filename)
|
743
|
-
begin
|
744
|
-
File.open(filename, (File::WRONLY | File::APPEND))
|
745
|
-
rescue Errno::ENOENT
|
746
|
-
create_logfile(filename)
|
747
|
-
end
|
748
|
-
end
|
749
|
-
|
750
|
-
def create_logfile(filename)
|
751
|
-
begin
|
752
|
-
logdev = File.open(filename, (File::WRONLY | File::APPEND | File::CREAT | File::EXCL))
|
753
|
-
logdev.flock(File::LOCK_EX)
|
754
|
-
logdev.sync = true
|
755
|
-
add_log_header(logdev)
|
756
|
-
logdev.flock(File::LOCK_UN)
|
757
|
-
rescue Errno::EEXIST
|
758
|
-
# file is created by another process
|
759
|
-
logdev = open_logfile(filename)
|
760
|
-
logdev.sync = true
|
761
|
-
end
|
762
|
-
logdev
|
763
|
-
end
|
764
|
-
|
765
|
-
def add_log_header(file)
|
766
|
-
file.write(
|
767
|
-
"# Logfile created on %s by %s\n" % [Time.now.to_s, Logger::ProgName]
|
768
|
-
) if file.size == 0
|
769
|
-
end
|
770
|
-
|
771
|
-
def check_shift_log
|
772
|
-
if @shift_age.is_a?(Integer)
|
773
|
-
# Note: always returns false if '0'.
|
774
|
-
if @filename && (@shift_age > 0) && (@dev.stat.size > @shift_size)
|
775
|
-
lock_shift_log { shift_log_age }
|
776
|
-
end
|
777
|
-
else
|
778
|
-
now = Time.now
|
779
|
-
if now >= @next_rotate_time
|
780
|
-
@next_rotate_time = next_rotate_time(now, @shift_age)
|
781
|
-
lock_shift_log { shift_log_period(previous_period_end(now, @shift_age)) }
|
782
|
-
end
|
783
|
-
end
|
784
|
-
end
|
785
|
-
|
786
|
-
if /mswin|mingw/ =~ RUBY_PLATFORM
|
787
|
-
def lock_shift_log
|
788
|
-
yield
|
789
|
-
end
|
790
|
-
else
|
791
|
-
def lock_shift_log
|
792
|
-
retry_limit = 8
|
793
|
-
retry_sleep = 0.1
|
794
|
-
begin
|
795
|
-
File.open(@filename, File::WRONLY | File::APPEND) do |lock|
|
796
|
-
lock.flock(File::LOCK_EX) # inter-process locking. will be unlocked at closing file
|
797
|
-
if File.identical?(@filename, lock) and File.identical?(lock, @dev)
|
798
|
-
yield # log shifting
|
799
|
-
else
|
800
|
-
# log shifted by another process (i-node before locking and i-node after locking are different)
|
801
|
-
@dev.close rescue nil
|
802
|
-
@dev = open_logfile(@filename)
|
803
|
-
@dev.sync = true
|
804
|
-
end
|
805
|
-
end
|
806
|
-
rescue Errno::ENOENT
|
807
|
-
# @filename file would not exist right after #rename and before #create_logfile
|
808
|
-
if retry_limit <= 0
|
809
|
-
warn("log rotation inter-process lock failed. #{$!}")
|
810
|
-
else
|
811
|
-
sleep retry_sleep
|
812
|
-
retry_limit -= 1
|
813
|
-
retry_sleep *= 2
|
814
|
-
retry
|
815
|
-
end
|
816
|
-
end
|
817
|
-
rescue
|
818
|
-
warn("log rotation inter-process lock failed. #{$!}")
|
819
|
-
end
|
820
|
-
end
|
821
|
-
|
822
|
-
def shift_log_age
|
823
|
-
(@shift_age-3).downto(0) do |i|
|
824
|
-
if FileTest.exist?("#{@filename}.#{i}")
|
825
|
-
File.rename("#{@filename}.#{i}", "#{@filename}.#{i+1}")
|
826
|
-
end
|
827
|
-
end
|
828
|
-
@dev.close rescue nil
|
829
|
-
File.rename("#{@filename}", "#{@filename}.0")
|
830
|
-
@dev = create_logfile(@filename)
|
831
|
-
return true
|
832
|
-
end
|
833
|
-
|
834
|
-
def shift_log_period(period_end)
|
835
|
-
suffix = period_end.strftime(@shift_period_suffix)
|
836
|
-
age_file = "#{@filename}.#{suffix}"
|
837
|
-
if FileTest.exist?(age_file)
|
838
|
-
# try to avoid filename crash caused by Timestamp change.
|
839
|
-
idx = 0
|
840
|
-
# .99 can be overridden; avoid too much file search with 'loop do'
|
841
|
-
while idx < 100
|
842
|
-
idx += 1
|
843
|
-
age_file = "#{@filename}.#{suffix}.#{idx}"
|
844
|
-
break unless FileTest.exist?(age_file)
|
845
|
-
end
|
846
|
-
end
|
847
|
-
@dev.close rescue nil
|
848
|
-
File.rename("#{@filename}", age_file)
|
849
|
-
@dev = create_logfile(@filename)
|
850
|
-
return true
|
851
|
-
end
|
852
|
-
end
|
853
586
|
end
|
data/logger.gemspec
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
begin
|
2
|
-
require_relative "lib/logger"
|
3
|
-
rescue LoadError
|
4
|
-
|
5
|
-
require_relative "logger"
|
2
|
+
require_relative "lib/logger/version"
|
3
|
+
rescue LoadError # Fallback to load version file in ruby core repository
|
4
|
+
require_relative "logger/version"
|
6
5
|
end
|
7
6
|
|
8
7
|
Gem::Specification.new do |spec|
|
9
8
|
spec.name = "logger"
|
10
9
|
spec.version = Logger::VERSION
|
11
|
-
spec.authors = ["SHIBATA Hiroshi"]
|
12
|
-
spec.email = ["hsbt@ruby-lang.org"]
|
10
|
+
spec.authors = ["Naotoshi Seo", "SHIBATA Hiroshi"]
|
11
|
+
spec.email = ["sonots@gmail.com", "hsbt@ruby-lang.org"]
|
13
12
|
|
14
13
|
spec.summary = %q{Provides a simple logging utility for outputting messages.}
|
15
14
|
spec.description = %q{Provides a simple logging utility for outputting messages.}
|
16
15
|
spec.homepage = "https://github.com/ruby/logger"
|
17
16
|
spec.license = "BSD-2-Clause"
|
18
17
|
|
19
|
-
spec.files = ["
|
18
|
+
spec.files = ["Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/logger.rb", "logger.gemspec"]
|
20
19
|
spec.bindir = "exe"
|
21
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
21
|
spec.require_paths = ["lib"]
|
23
22
|
|
24
|
-
spec.
|
23
|
+
spec.required_ruby_version = ">= 2.3.0"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", ">= 0"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
-
spec.add_development_dependency "
|
27
|
+
spec.add_development_dependency "test-unit"
|
28
|
+
spec.add_development_dependency "rdoc"
|
27
29
|
end
|
metadata
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Naotoshi Seo
|
7
8
|
- SHIBATA Hiroshi
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - "
|
18
|
+
- - ">="
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
+
version: '0'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - "
|
25
|
+
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
+
version: '0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,34 +40,45 @@ dependencies:
|
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '10.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
+
name: test-unit
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - "
|
46
|
+
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
+
version: '0'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - "
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rdoc
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
53
61
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
55
70
|
description: Provides a simple logging utility for outputting messages.
|
56
71
|
email:
|
72
|
+
- sonots@gmail.com
|
57
73
|
- hsbt@ruby-lang.org
|
58
74
|
executables: []
|
59
75
|
extensions: []
|
60
76
|
extra_rdoc_files: []
|
61
77
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
78
|
- Gemfile
|
65
79
|
- LICENSE.txt
|
66
80
|
- README.md
|
67
81
|
- Rakefile
|
68
|
-
- bin/console
|
69
|
-
- bin/setup
|
70
82
|
- lib/logger.rb
|
71
83
|
- logger.gemspec
|
72
84
|
homepage: https://github.com/ruby/logger
|
@@ -81,15 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
93
|
requirements:
|
82
94
|
- - ">="
|
83
95
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
96
|
+
version: 2.3.0
|
85
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
99
|
- - ">="
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: '0'
|
90
102
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.7.6
|
103
|
+
rubygems_version: 3.0.3
|
93
104
|
signing_key:
|
94
105
|
specification_version: 4
|
95
106
|
summary: Provides a simple logging utility for outputting messages.
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
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__)
|