ci_logger 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/ci_logger/formatter.rb +37 -0
- data/lib/ci_logger/logger.rb +25 -7
- data/lib/ci_logger/version.rb +1 -1
- data/lib/ci_logger.rb +1 -30
- 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: 11629fb2dce2cdff3c3e940151e40efd927ac0b780981a644a03b493cee90131
|
4
|
+
data.tar.gz: 277aab9b4b91ac63c8be5d2fc18cf7cc0ef6cd906f2d89e30dc8a6d721f504a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b4a46f290717e27a7c9a69141a5b31c96702983a19262a16e88224e7672167b900858f423f65fbce9f07ac00bce8791eca73f2299f0a234b24cc6542c86fec
|
7
|
+
data.tar.gz: 5a0a4624f2541e88ba8ba2b65f105f9288d700c0eb03c3b089437df64269c8975d5cf469a77ffc0af0915f7d8df7c8cbb76dd351b837d9ebd2c9565a47af1c29
|
data/README.md
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "rspec/core"
|
2
|
+
|
3
|
+
module CiLogger
|
4
|
+
class Formatter
|
5
|
+
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
|
6
|
+
|
7
|
+
def initialize(_out)
|
8
|
+
@out = _out
|
9
|
+
end
|
10
|
+
|
11
|
+
def example_failed(notification)
|
12
|
+
if Rails.application.config.ci_logger.enabled
|
13
|
+
example = notification.example
|
14
|
+
Rails.logger.debug("finish example at #{example.location}")
|
15
|
+
Rails.logger.sync
|
16
|
+
else
|
17
|
+
Rails.logger.sync_with_original_level
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def example_passed(_notification)
|
22
|
+
if Rails.application.config.ci_logger.enabled
|
23
|
+
Rails.logger.clear
|
24
|
+
else
|
25
|
+
Rails.logger.sync_with_original_level
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def example_pending(_notification)
|
30
|
+
if Rails.application.config.ci_logger.enabled
|
31
|
+
Rails.logger.clear
|
32
|
+
else
|
33
|
+
Rails.logger.sync_with_original_level
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ci_logger/logger.rb
CHANGED
@@ -2,14 +2,33 @@ module CiLogger
|
|
2
2
|
class Logger < ::Logger
|
3
3
|
def initialize(original)
|
4
4
|
@original = original
|
5
|
+
@original_level = @original.level
|
5
6
|
@original.level = :debug
|
6
7
|
self.level = :debug
|
7
8
|
end
|
8
9
|
|
10
|
+
def sync
|
11
|
+
temporary_log.each do |l|
|
12
|
+
if @level <= l[:severity]
|
13
|
+
@original.add(l[:severity], l[:message], l[:progname])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
temporary_log.clear
|
17
|
+
end
|
18
|
+
|
19
|
+
def sync_with_original_level
|
20
|
+
@original.level = @original_level
|
21
|
+
sync
|
22
|
+
ensure
|
23
|
+
@original.level = :debug
|
24
|
+
end
|
25
|
+
|
9
26
|
def clear
|
10
27
|
temporary_log.clear
|
11
28
|
end
|
12
29
|
|
30
|
+
private
|
31
|
+
|
13
32
|
def temporary_log
|
14
33
|
@temporary_log ||= []
|
15
34
|
end
|
@@ -18,13 +37,12 @@ module CiLogger
|
|
18
37
|
temporary_log << { severity: severity, message: message, progname: progname }
|
19
38
|
end
|
20
39
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
temporary_log.clear
|
40
|
+
def method_missing(symbol, *args, &block)
|
41
|
+
@original.send(symbol, *args, &block)
|
42
|
+
end
|
43
|
+
|
44
|
+
def respond_to_missing?(symbol, include_all)
|
45
|
+
@original.respond_to?(symbol, include_all)
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
data/lib/ci_logger/version.rb
CHANGED
data/lib/ci_logger.rb
CHANGED
@@ -1,36 +1,7 @@
|
|
1
1
|
require "ci_logger/version"
|
2
2
|
require "ci_logger/railtie"
|
3
3
|
require "ci_logger/logger"
|
4
|
+
require "ci_logger/formatter"
|
4
5
|
|
5
6
|
module CiLogger
|
6
|
-
begin
|
7
|
-
require "rspec/rails"
|
8
|
-
|
9
|
-
class Formatter
|
10
|
-
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
|
11
|
-
|
12
|
-
def initialize(_out)
|
13
|
-
@out = _out
|
14
|
-
end
|
15
|
-
|
16
|
-
def example_failed(notification)
|
17
|
-
if Rails.application.config.ci_logger.enabled
|
18
|
-
example = notification.example
|
19
|
-
Rails.logger.debug("finish example at #{example.location}")
|
20
|
-
Rails.logger.sync
|
21
|
-
else
|
22
|
-
Rails.logger.clear
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def example_passed(_notification)
|
27
|
-
Rails.logger.clear
|
28
|
-
end
|
29
|
-
|
30
|
-
def example_pending(_notification)
|
31
|
-
Rails.logger.clear
|
32
|
-
end
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
end
|
36
7
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 5.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec-
|
28
|
+
name: rspec-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Faster logger for CI
|
42
56
|
email:
|
43
57
|
- netwillnet@gmail.com
|
@@ -49,6 +63,7 @@ files:
|
|
49
63
|
- README.md
|
50
64
|
- Rakefile
|
51
65
|
- lib/ci_logger.rb
|
66
|
+
- lib/ci_logger/formatter.rb
|
52
67
|
- lib/ci_logger/logger.rb
|
53
68
|
- lib/ci_logger/railtie.rb
|
54
69
|
- lib/ci_logger/version.rb
|