ci_logger 0.1.3 → 0.2.3
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/ci_logger/logger.rb +37 -8
- data/lib/ci_logger/railtie.rb +2 -2
- data/lib/ci_logger/rspec_formatter.rb +37 -0
- data/lib/ci_logger/version.rb +1 -1
- data/lib/ci_logger.rb +1 -27
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cf7f2dd60a91e9fa17277d37076bb7dbf25b9113b49c1bcf845d338121315bd
|
4
|
+
data.tar.gz: 2061f9ff81b43d5f884cfe069adbd098ad3677b9ea0c823d1e2499638ede8510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1dc04cf494366424732fba457af6b7b5afc4a7a385f83971464e31af238acac51ac73bac9b4261198aff04f3c6dc625c48bc20add75f2c76bea5380f3b94ae45
|
7
|
+
data.tar.gz: 13d36af5c45028117b6e8a6ce865b67146b9663d919371d29b3da3f36fcb24c7ce10027ae9eb24695baf65496e388097ccf0c70bdfe91e7239716325b72d87e1
|
data/lib/ci_logger/logger.rb
CHANGED
@@ -2,29 +2,58 @@ 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
|
+
def formatter
|
31
|
+
@original.formatter
|
32
|
+
end
|
33
|
+
|
34
|
+
def formatter=(f)
|
35
|
+
@original.formatter = f
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
13
40
|
def temporary_log
|
14
41
|
@temporary_log ||= []
|
15
42
|
end
|
16
43
|
|
17
44
|
def add(severity, message = nil, progname = nil)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
45
|
+
if progname.nil?
|
46
|
+
progname = @progname
|
47
|
+
end
|
48
|
+
if message.nil?
|
49
|
+
if block_given?
|
50
|
+
message = yield
|
51
|
+
else
|
52
|
+
message = progname
|
53
|
+
progname = @progname
|
25
54
|
end
|
26
55
|
end
|
27
|
-
temporary_log
|
56
|
+
temporary_log << { severity: severity, message: message, progname: progname }
|
28
57
|
end
|
29
58
|
|
30
59
|
def method_missing(symbol, *args, &block)
|
data/lib/ci_logger/railtie.rb
CHANGED
@@ -8,8 +8,8 @@ module CiLogger
|
|
8
8
|
Rails.logger = CiLogger::Logger.new(Rails.logger)
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
|
-
config.add_formatter 'progress'
|
12
|
-
config.add_formatter ::CiLogger::
|
11
|
+
config.add_formatter 'progress' if config.formatters.empty?
|
12
|
+
config.add_formatter ::CiLogger::RspecFormatter
|
13
13
|
config.before do |example|
|
14
14
|
Rails.logger.debug("start example at #{example.location}")
|
15
15
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "rspec/core"
|
2
|
+
|
3
|
+
module CiLogger
|
4
|
+
class RspecFormatter
|
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/version.rb
CHANGED
data/lib/ci_logger.rb
CHANGED
@@ -1,33 +1,7 @@
|
|
1
1
|
require "ci_logger/version"
|
2
2
|
require "ci_logger/railtie"
|
3
3
|
require "ci_logger/logger"
|
4
|
+
require "ci_logger/rspec_formatter"
|
4
5
|
|
5
6
|
module CiLogger
|
6
|
-
require "rspec/core"
|
7
|
-
|
8
|
-
class Formatter
|
9
|
-
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
|
10
|
-
|
11
|
-
def initialize(_out)
|
12
|
-
@out = _out
|
13
|
-
end
|
14
|
-
|
15
|
-
def example_failed(notification)
|
16
|
-
if Rails.application.config.ci_logger.enabled
|
17
|
-
example = notification.example
|
18
|
-
Rails.logger.debug("finish example at #{example.location}")
|
19
|
-
Rails.logger.sync
|
20
|
-
else
|
21
|
-
Rails.logger.clear
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def example_passed(_notification)
|
26
|
-
Rails.logger.clear
|
27
|
-
end
|
28
|
-
|
29
|
-
def example_pending(_notification)
|
30
|
-
Rails.logger.clear
|
31
|
-
end
|
32
|
-
end
|
33
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/ci_logger.rb
|
66
66
|
- lib/ci_logger/logger.rb
|
67
67
|
- lib/ci_logger/railtie.rb
|
68
|
+
- lib/ci_logger/rspec_formatter.rb
|
68
69
|
- lib/ci_logger/version.rb
|
69
70
|
- lib/tasks/ci_logger_tasks.rake
|
70
71
|
homepage: https://github.com/willnet/ci_logger
|
@@ -74,7 +75,7 @@ metadata:
|
|
74
75
|
homepage_uri: https://github.com/willnet/ci_logger
|
75
76
|
source_code_uri: https://github.com/willnet/ci_logger
|
76
77
|
changelog_uri: https://github.com/willnet/ci_logger
|
77
|
-
post_install_message:
|
78
|
+
post_install_message:
|
78
79
|
rdoc_options: []
|
79
80
|
require_paths:
|
80
81
|
- lib
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubygems_version: 3.2.22
|
93
|
-
signing_key:
|
94
|
+
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: Faster logger for CI
|
96
97
|
test_files: []
|