ci_logger 0.6.0 → 0.7.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/README.md +9 -0
- data/lib/ci_logger/logger.rb +3 -0
- data/lib/ci_logger/minitest/integration.rb +4 -4
- data/lib/ci_logger/railtie.rb +1 -1
- data/lib/ci_logger/registry.rb +22 -0
- data/lib/ci_logger/rspec/integration.rb +7 -7
- data/lib/ci_logger/version.rb +1 -1
- data/lib/ci_logger.rb +13 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51c9f02d787a2ea528d373395735b2a3f442c410b371b3a678cff837245056e2
|
4
|
+
data.tar.gz: b64fc8ea5f7f8590cf102b6ceb24bf47b113014061b526753ed12a22c8eec166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acfa40bed44dc82d44e311cf5a8124c32545176d8361e57e3fa82ae0b6a3bcc20bb3a201a4a6b84338eb6e4fc27d447e8ca8efaad14fe23343cbe24b5e08cbe8
|
7
|
+
data.tar.gz: 0eb2d0c042f3e926ee34368e9681200f676f30f54860bad8ff636b44c952e3cd94ec86084bbf77966d3ec529e815cb3995eebb71070b6dd10fb7836866f3a6bf
|
data/README.md
CHANGED
@@ -35,6 +35,15 @@ config.ci_logger.enabled = ENV['CI']
|
|
35
35
|
|
36
36
|
You can replace `ENV['CI']` with what you like.
|
37
37
|
|
38
|
+
## Replace loggers besides rails logger
|
39
|
+
|
40
|
+
CiLogger replaces Rails.logger by default, but other loggers can be replaced.
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
your_logger = CiLogger.new(your_logger)
|
44
|
+
your_logger.debug('debug!') # This is only output when the test fails
|
45
|
+
```
|
46
|
+
|
38
47
|
## Contributing
|
39
48
|
Contribution directions go here.
|
40
49
|
|
data/lib/ci_logger/logger.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "ci_logger/registry"
|
2
|
+
|
1
3
|
module CiLogger
|
2
4
|
class Logger < ::Logger
|
3
5
|
def initialize(original)
|
@@ -5,6 +7,7 @@ module CiLogger
|
|
5
7
|
@original_level = @original.level
|
6
8
|
@original.level = :debug
|
7
9
|
self.level = :debug
|
10
|
+
Registry.register(self)
|
8
11
|
end
|
9
12
|
|
10
13
|
def sync
|
@@ -3,12 +3,12 @@ module CiLogger
|
|
3
3
|
module Integration
|
4
4
|
def before_teardown
|
5
5
|
super
|
6
|
-
if
|
7
|
-
|
6
|
+
if CiLogger.disabled?
|
7
|
+
Registry.sync
|
8
8
|
elsif passed? || skipped?
|
9
|
-
|
9
|
+
Registry.clear
|
10
10
|
else
|
11
|
-
|
11
|
+
Registry.sync
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/ci_logger/railtie.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module CiLogger
|
2
|
+
module Registry
|
3
|
+
class << self
|
4
|
+
def register(logger)
|
5
|
+
@loggers ||= []
|
6
|
+
@loggers << logger
|
7
|
+
end
|
8
|
+
|
9
|
+
def sync
|
10
|
+
@loggers.each(&:sync)
|
11
|
+
end
|
12
|
+
|
13
|
+
def clear
|
14
|
+
@loggers.each(&:clear)
|
15
|
+
end
|
16
|
+
|
17
|
+
def debug(...)
|
18
|
+
@loggers.each { _1.debug(...) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -4,19 +4,19 @@ RSpec.configure do |config|
|
|
4
4
|
config.include CiLogger::Rspec::ExampleGroupMethods
|
5
5
|
|
6
6
|
config.prepend_before do |example|
|
7
|
-
next
|
7
|
+
next if CiLogger.disabled?
|
8
8
|
|
9
|
-
|
9
|
+
CiLogger::Registry.debug("start example at #{example.location}")
|
10
10
|
end
|
11
11
|
|
12
12
|
config.append_after do |example|
|
13
|
-
if
|
14
|
-
|
13
|
+
if CiLogger.disabled?
|
14
|
+
CiLogger::Registry.sync
|
15
15
|
elsif passed?
|
16
|
-
|
16
|
+
CiLogger::Registry.clear
|
17
17
|
else
|
18
|
-
|
19
|
-
|
18
|
+
CiLogger::Registry.debug("finish example at #{example.location}")
|
19
|
+
CiLogger::Registry.sync
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/ci_logger/version.rb
CHANGED
data/lib/ci_logger.rb
CHANGED
@@ -3,4 +3,17 @@ require "ci_logger/railtie"
|
|
3
3
|
require "ci_logger/logger"
|
4
4
|
|
5
5
|
module CiLogger
|
6
|
+
class << self
|
7
|
+
def new(original)
|
8
|
+
Logger.new(original)
|
9
|
+
end
|
10
|
+
|
11
|
+
def enabled?
|
12
|
+
Rails.application.config.ci_logger.enabled
|
13
|
+
end
|
14
|
+
|
15
|
+
def disabled?
|
16
|
+
!enabled?
|
17
|
+
end
|
18
|
+
end
|
6
19
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/ci_logger/logger.rb
|
53
53
|
- lib/ci_logger/minitest/integration.rb
|
54
54
|
- lib/ci_logger/railtie.rb
|
55
|
+
- lib/ci_logger/registry.rb
|
55
56
|
- lib/ci_logger/rspec/example_group_methods.rb
|
56
57
|
- lib/ci_logger/rspec/integration.rb
|
57
58
|
- lib/ci_logger/version.rb
|