chrono_logger 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 97bed9c7ad6f06d08927b617a1d7b75f2e95aa55
4
- data.tar.gz: 8276b26110368c35b54b2ea1eaf12bdd073034a8
2
+ SHA256:
3
+ metadata.gz: ee8232f6e93fdb6766c7685404c008954c26570cc08ee7d9a26df0492b721ad3
4
+ data.tar.gz: 8c362f4ef826b32830a4326ee6929fc6731579cb0a55f871757fcc4233338ea2
5
5
  SHA512:
6
- metadata.gz: c2c29589a695f8bb9657803e44d307939c7affe75a2f2d153a1903eef0ef41705f014a4ddb319d117484017bd50b28cfabfe2d5da4f190bfa1a030a32d499535
7
- data.tar.gz: 8d0524b4bfb8a4b6228cf9ce1b93e9755e33911692e9de42759baa2908a7a5ff4561a97e1e6cca9090c749672e4e868c00dfcff771c201c63541629b8122d00d
6
+ metadata.gz: 60f8897ee73f13eedc17b65de6c0c64339827c6abd6b8892ed95a81ad24c50f3b346b5a4667f721a2c3183cefcd9384ca0f293623c1805befb1b863695976525
7
+ data.tar.gz: e4676e13ab6e54452249fa1e089d96e1d19a5d76c935ff8cc9945592b5f47a421ce6ecf7e833363dc3f408a94975bc178442dc97182e00908c792d491fec2455
@@ -0,0 +1,36 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+
15
+ jobs:
16
+ test:
17
+
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby: [ '2.6', '2.7', '3.0', '3.1' ]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby
26
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
27
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+ - name: Install dependencies
32
+ run: |
33
+ bundle config path vendor/bundle
34
+ bundle install --jobs 4 --retry 3
35
+ - name: Run tests
36
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # ChronoLogger
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/chrono_logger.svg)](http://badge.fury.io/rb/chrono_logger)
4
- [![Build Status](https://travis-ci.org/ma2gedev/chrono_logger.svg)](https://travis-ci.org/ma2gedev/chrono_logger)
4
+ [![Build Status](https://github.com/ma2gedev/chrono_logger/workflows/Ruby/badge.svg?branch=master)](https://github.com/ma2gedev/chrono_logger/actions?query=workflow%3ARuby)
5
5
  [![Code Climate](https://codeclimate.com/github/ma2gedev/chrono_logger/badges/gpa.svg)](https://codeclimate.com/github/ma2gedev/chrono_logger)
6
- [![Coverage Status](https://coveralls.io/repos/ma2gedev/chrono_logger/badge.svg)](https://coveralls.io/r/ma2gedev/chrono_logger)
7
- [![Inline docs](http://inch-ci.org/github/ma2gedev/chrono_logger.svg?branch=master)](http://inch-ci.org/github/ma2gedev/chrono_logger)
8
- [![endorse](https://api.coderwall.com/ma2gedev/endorsecount.png)](https://coderwall.com/ma2gedev)
9
6
 
10
7
  A lock-free logger with timebased file rotation.
11
8
 
@@ -108,7 +105,3 @@ MIT. See [LICENSE.txt](LICENSE.txt) for more details.
108
105
 
109
106
  - [ChronoLogger logging is 1.5x faster than ruby's stdlib Logger](https://coderwall.com/p/vjjszq/chronologger-logging-is-1-5x-faster-than-ruby-s-stdlib-logger)
110
107
 
111
-
112
-
113
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ma2gedev/chrono_logger/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
114
-
@@ -18,13 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rake", ">= 0"
23
22
  spec.add_development_dependency "test-unit"
24
23
  spec.add_development_dependency "pry"
25
24
  spec.add_development_dependency "delorean"
26
25
  spec.add_development_dependency "parallel"
27
- spec.add_development_dependency "coveralls"
26
+ spec.add_development_dependency "simplecov"
28
27
 
29
28
  # for performance check
30
29
  spec.add_development_dependency "mono_logger"
@@ -1,5 +1,5 @@
1
1
  require 'logger'
2
2
 
3
3
  class ChronoLogger < Logger
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
data/lib/chrono_logger.rb CHANGED
@@ -54,7 +54,7 @@ class ChronoLogger < Logger
54
54
  DELAY_SECOND_TO_CLOSE_FILE = 5
55
55
 
56
56
  def initialize(log = nil, opt = {})
57
- @dev = @filename = nil
57
+ @dev = @filename = @pattern = nil
58
58
  if defined?(LogDeviceMutex) # Ruby < 2.3
59
59
  @mutex = LogDeviceMutex.new
60
60
  else
@@ -138,7 +138,7 @@ class ChronoLogger < Logger
138
138
  end
139
139
  end
140
140
  rescue Exception => ignored
141
- warn("log shifting failed. #{$!}")
141
+ warn("log shifting failed. #{ignored}")
142
142
  end
143
143
  end
144
144
  end
@@ -12,6 +12,7 @@ class TestLogger < Test::Unit::TestCase
12
12
  class Log
13
13
  attr_reader :label, :datetime, :pid, :severity, :progname, :msg
14
14
  def initialize(line)
15
+ # NOTE: adapt the following pattern ruby's original test after support only ruby 3.1 or higher
15
16
  /\A(\w+), \[([^#]*)#(\d+)\]\s+(\w+) -- (\w*): ([\x0-\xff]*)/ =~ line
16
17
  @label, @datetime, @pid, @severity, @progname, @msg = $1, $2, $3, $4, $5, $6
17
18
  end
@@ -82,10 +83,11 @@ class TestLogger < Test::Unit::TestCase
82
83
  assert_match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\s*\d+ $/, log.datetime)
83
84
  logger.datetime_format = "%d%b%Y@%H:%M:%S"
84
85
  log = log_add(logger, INFO, "foo")
85
- assert_match(/^\d\d\w\w\w\d\d\d\d@\d\d:\d\d:\d\d$/, log.datetime)
86
+ # NOTE: ` ?` contained in the following will be removed after support only ruby 3.1 or higher
87
+ assert_match(/^\d\d\w\w\w\d\d\d\d@\d\d:\d\d:\d\d ?$/, log.datetime)
86
88
  logger.datetime_format = ""
87
89
  log = log_add(logger, INFO, "foo")
88
- assert_match(/^$/, log.datetime)
90
+ assert_match(/^ ?$/, log.datetime)
89
91
  end
90
92
 
91
93
  def test_formatter
data/test/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'coveralls'
2
- Coveralls.wear!
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
5
  require 'chrono_logger'
@@ -29,6 +29,31 @@ class TestChronoLogger < Test::Unit::TestCase
29
29
  confirm_daily_rotation(in_processes: 2)
30
30
  end
31
31
 
32
+ def test_exception_on_shifting_log
33
+ old_log = [@tempfile.path, '20220101'].join
34
+ new_log = [@tempfile.path, '20220102'].join
35
+ $stderr, stderr = StringIO.new, $stderr
36
+ begin
37
+ Delorean.time_travel_to '2022-01-01 23:59:59.990'
38
+ logger = ChronoLogger.new(@format)
39
+ old_logdev = logger.instance_variable_get('@logdev')
40
+ def old_logdev.create_logfile(filename)
41
+ raise 'override create_logfile method'
42
+ end
43
+ sleep 1 # waiting for shift log file
44
+
45
+ logger.info 'shift log'
46
+
47
+ assert_match(/log shifting failed\. override create_logfile method/, $stderr.string)
48
+ assert { File.exist?(old_log) }
49
+ assert { !File.exist?(new_log) }
50
+ ensure
51
+ $stderr, stderr = stderr, $stderr
52
+ Delorean.back_to_the_present
53
+ File.unlink(old_log)
54
+ end
55
+ end
56
+
32
57
  def test_rotation_per_second
33
58
  Dir.mktmpdir do |tmpdir|
34
59
  begin
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrono_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takayuki Matsubara
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2022-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '10.0'
19
+ version: '0'
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '10.0'
26
+ version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: test-unit
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +81,7 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: coveralls
84
+ name: simplecov
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -143,8 +129,8 @@ executables: []
143
129
  extensions: []
144
130
  extra_rdoc_files: []
145
131
  files:
132
+ - ".github/workflows/ruby.yml"
146
133
  - ".gitignore"
147
- - ".travis.yml"
148
134
  - CHANGELOG.md
149
135
  - Gemfile
150
136
  - LICENSE.txt
@@ -162,7 +148,7 @@ homepage: https://github.com/ma2gedev/chrono_logger
162
148
  licenses:
163
149
  - MIT
164
150
  metadata: {}
165
- post_install_message:
151
+ post_install_message:
166
152
  rdoc_options: []
167
153
  require_paths:
168
154
  - lib
@@ -177,9 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
163
  - !ruby/object:Gem::Version
178
164
  version: '0'
179
165
  requirements: []
180
- rubyforge_project:
181
- rubygems_version: 2.2.2
182
- signing_key:
166
+ rubygems_version: 3.2.3
167
+ signing_key:
183
168
  specification_version: 4
184
169
  summary: A lock-free logger with timebased file rotation.
185
170
  test_files:
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0-p598
4
- - 2.1.5
5
- - 2.2.0
6
- - 2.3.0
7
- sudo: false
8
- cache: bundler