ci_logger 0.1.1 → 0.2.1
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/README.md +1 -1
- data/lib/ci_logger/logger.rb +33 -7
- data/lib/ci_logger/railtie.rb +1 -1
- data/lib/ci_logger/rspec_formatter.rb +37 -0
- data/lib/ci_logger/version.rb +1 -1
- data/lib/ci_logger.rb +1 -30
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e72539f48e1d431cf0aea68bc94bc68f634ff387ab7f403e3a32b0dc8e5968
|
4
|
+
data.tar.gz: f702a6a73bdaacad98c3c145fe143479d7e5f2ba0eb30fddea8ba418c6007cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e497db83054eb3fe825ab4ff04046e9fa1e9bb0960b7a4222975eb6896f8368397d352808d7bea4c6d3636016b71eeaec9327ae2fbd18d849905fd9a4d0fba
|
7
|
+
data.tar.gz: aec951a589e55cd68c65a5eeda83a5fe82f891c93df407017ae2bf487c82b8cb03beb545bf8c72231fdeba886a8805522104109ca03e025de36d5e254819e399
|
data/README.md
CHANGED
data/lib/ci_logger/logger.rb
CHANGED
@@ -2,14 +2,41 @@ 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
|
@@ -18,13 +45,12 @@ module CiLogger
|
|
18
45
|
temporary_log << { severity: severity, message: message, progname: progname }
|
19
46
|
end
|
20
47
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
temporary_log.clear
|
48
|
+
def method_missing(symbol, *args, &block)
|
49
|
+
@original.send(symbol, *args, &block)
|
50
|
+
end
|
51
|
+
|
52
|
+
def respond_to_missing?(symbol, include_all)
|
53
|
+
@original.respond_to?(symbol, include_all)
|
28
54
|
end
|
29
55
|
end
|
30
56
|
end
|
data/lib/ci_logger/railtie.rb
CHANGED
@@ -9,7 +9,7 @@ module CiLogger
|
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
11
|
config.add_formatter 'progress'
|
12
|
-
config.add_formatter ::CiLogger::
|
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,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/rspec_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,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.1
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -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
|
@@ -51,6 +65,7 @@ files:
|
|
51
65
|
- lib/ci_logger.rb
|
52
66
|
- lib/ci_logger/logger.rb
|
53
67
|
- lib/ci_logger/railtie.rb
|
68
|
+
- lib/ci_logger/rspec_formatter.rb
|
54
69
|
- lib/ci_logger/version.rb
|
55
70
|
- lib/tasks/ci_logger_tasks.rake
|
56
71
|
homepage: https://github.com/willnet/ci_logger
|