ci_logger 0.7.0 → 0.9.0

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
2
  SHA256:
3
- metadata.gz: 51c9f02d787a2ea528d373395735b2a3f442c410b371b3a678cff837245056e2
4
- data.tar.gz: b64fc8ea5f7f8590cf102b6ceb24bf47b113014061b526753ed12a22c8eec166
3
+ metadata.gz: 1ce341924bdc0f1a3761810fb5d58009a503cd9688b54deb96851e13e6f2ffaf
4
+ data.tar.gz: 1934aeee05c62941aec7eb654453444a3e1b10878d34e1e3348b388c25f01897
5
5
  SHA512:
6
- metadata.gz: acfa40bed44dc82d44e311cf5a8124c32545176d8361e57e3fa82ae0b6a3bcc20bb3a201a4a6b84338eb6e4fc27d447e8ca8efaad14fe23343cbe24b5e08cbe8
7
- data.tar.gz: 0eb2d0c042f3e926ee34368e9681200f676f30f54860bad8ff636b44c952e3cd94ec86084bbf77966d3ec529e815cb3995eebb71070b6dd10fb7836866f3a6bf
6
+ metadata.gz: 80239a598de56634fafb6dfda2789daeb45fe930689299a5e33bc57bf5ec61d2b79c43e0c6bfb18cf35e4faf0964a257755aadb261f5a0523c7335b6124b31ed
7
+ data.tar.gz: 032d18696a2d8c1a94cdbf50c7e293298e58bab9b6a288c6abff751b59ab38e8f41ac7b498fd62af04900a0e9428f899fa6af551b348f4101ba821147dd01bd5
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # CiLogger
2
2
 
3
- We perform a significant number of tests using CI on a daily basis. Whenever a test fails, we need to examine the log. However, the current log output is excessively large, making it challenging to identify the root cause of the failed test.
3
+ In our CI process, we often look at logs to figure out issues with flaky tests—tests that fail sometimes but not always, especially when we can't make them fail in the same way on our own computers. The problem is, it's hard to tell which logs are about the failed tests because logs from tests that passed and failed are all mixed together.
4
4
 
5
- CiLogger specifically generates logs for failed tests, which proves invaluable during the investigation of test failures.
5
+ CiLogger makes this easier by only keeping logs from tests that didn't pass, including the tricky flaky ones. This means when a flaky test won't fail the same way for us locally, we can quickly find and look at the right logs to help us understand and fix the problem.
6
6
 
7
7
  ## prerequisite
8
8
 
9
9
  - rspec or minitest
10
- - rails(>= 6.0)
10
+ - rails(>= 6.1)
11
11
 
12
12
  ## Installation
13
13
 
@@ -1,49 +1,23 @@
1
1
  require "ci_logger/registry"
2
2
 
3
3
  module CiLogger
4
- class Logger < ::Logger
4
+ class Logger
5
5
  def initialize(original)
6
6
  @original = original
7
- @original_level = @original.level
8
- @original.level = :debug
9
- self.level = :debug
10
7
  Registry.register(self)
11
8
  end
12
9
 
13
10
  def sync
14
11
  temporary_log.each do |l|
15
- if @level <= l[:severity]
16
- @original.add(l[:severity], l[:message], l[:progname])
17
- end
12
+ @original.add(l[:severity], l[:message], l[:progname])
18
13
  end
19
14
  temporary_log.clear
20
15
  end
21
16
 
22
- def sync_with_original_level
23
- @original.level = @original_level
24
- sync
25
- ensure
26
- @original.level = :debug
27
- end
28
-
29
17
  def clear
30
18
  temporary_log.clear
31
19
  end
32
20
 
33
- def formatter
34
- @original.formatter
35
- end
36
-
37
- def formatter=(f)
38
- @original.formatter = f
39
- end
40
-
41
- private
42
-
43
- def temporary_log
44
- @temporary_log ||= []
45
- end
46
-
47
21
  def add(severity, message = nil, progname = nil)
48
22
  if progname.nil?
49
23
  progname = @progname
@@ -59,12 +33,42 @@ module CiLogger
59
33
  temporary_log << { severity: severity, message: message, progname: progname }
60
34
  end
61
35
 
62
- def method_missing(symbol, *args, &block)
63
- @original.send(symbol, *args, &block)
36
+ def debug(progname = nil, &block)
37
+ add(::Logger::DEBUG, nil, progname, &block)
38
+ end
39
+
40
+ def info(progname = nil, &block)
41
+ add(::Logger::INFO, nil, progname, &block)
42
+ end
43
+
44
+ def warn(progname = nil, &block)
45
+ add(::Logger::WARN, nil, progname, &block)
46
+ end
47
+
48
+ def error(progname = nil, &block)
49
+ add(::Logger::ERROR, nil, progname, &block)
50
+ end
51
+
52
+ def fatal(progname = nil, &block)
53
+ add(::Logger::FATAL, nil, progname, &block)
54
+ end
55
+
56
+ def unknown(progname = nil, &block)
57
+ add(::Logger::UNKNOWN, nil, progname, &block)
58
+ end
59
+
60
+ private
61
+
62
+ def temporary_log
63
+ @temporary_log ||= []
64
+ end
65
+
66
+ def method_missing(...)
67
+ @original.send(...)
64
68
  end
65
69
 
66
- def respond_to_missing?(symbol, include_all)
67
- @original.respond_to?(symbol, include_all)
70
+ def respond_to_missing?(...)
71
+ @original.respond_to?(...)
68
72
  end
69
73
  end
70
74
  end
@@ -5,7 +5,14 @@ module CiLogger
5
5
 
6
6
  config.before_initialize do
7
7
  if CiLogger.enabled?
8
- Rails.logger = CiLogger::Logger.new(Rails.logger)
8
+ if defined?(ActiveSupport::BroadcastLogger) && Rails.logger.is_a?(ActiveSupport::BroadcastLogger)
9
+ Rails.logger.instance_variable_get(:@broadcasts).map! do |logger|
10
+ CiLogger::Logger.new(logger)
11
+ end
12
+ else
13
+ Rails.logger = CiLogger::Logger.new(Rails.logger)
14
+ end
15
+
9
16
  begin
10
17
  require "rspec/core"
11
18
  require "ci_logger/rspec/integration"
@@ -1,3 +1,3 @@
1
1
  module CiLogger
2
- VERSION = '0.7.0'
2
+ VERSION = '0.9.0'
3
3
  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.7.0
4
+ version: 0.9.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-09-09 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 6.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.0
26
+ version: 6.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  requirements: []
82
- rubygems_version: 3.4.17
82
+ rubygems_version: 3.4.22
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Faster logger for CI