testa_logger 0.1.20 → 0.1.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4069ae4029ec3f11274260b73d65fb7d45991d7fb037c36d1b111ed8a32ab3b
4
- data.tar.gz: 71a36a5224bd3b057936519fc459ee9958939bf66b1b779d86b12a26c51b5e28
3
+ metadata.gz: 6708e43ab4dcbe981946cd58d3a7361816418b9531c2a8c233afac1156df100e
4
+ data.tar.gz: 29ce587bf7b6774700ce59ceb8890dcafc3804b823205e2b0634b9a385d73ca9
5
5
  SHA512:
6
- metadata.gz: 6f64334d97044c3fc3d5851c73453d1819b78ab447ae6d7a4e9f995ca64a518bd2b781d0611278fc0a0315f51729ae76ab975a93e3b204d17586c964d39ad85e
7
- data.tar.gz: 40523364197a2e26399011dd6720e972c4cc586ba63fe96fa21eee42ebd0ca6adc7c0b794245e957fc3d8256310179258e4bde3435f186cae200db94eb0652e7
6
+ metadata.gz: 293b25ea6a8164c825b5a90c1483fa6e92ecb77aa596f90409ce2300477d2c47fc87b980736883446d880585b45673e41ccb8ab86df93a7f17545cfde55b2b69
7
+ data.tar.gz: 02142f209b35738a08248956c833619d5205dee4e58dd3a1a7e827e9a1dfe3108feaf2258d24c03839cca54b78b55d33476a9a07e4001ce04871219ae4a5dd9c
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in testa_logger.gemspec
4
4
  gemspec
5
5
 
6
+ gem "at_fork", git: "http://github.com/Vasfed/at_fork"
6
7
  gem "minitest", "~> 5.0"
7
8
  gem "rake", "~> 12.0"
8
9
  gem "rubocop", "~> 1.26.0", require: false
data/Gemfile.lock CHANGED
@@ -1,8 +1,15 @@
1
+ GIT
2
+ remote: http://github.com/Vasfed/at_fork
3
+ revision: b32ef8dfb0dfac6e05bcca80179f982cded69caa
4
+ specs:
5
+ at_fork (0.0.1)
6
+
1
7
  PATH
2
8
  remote: .
3
9
  specs:
4
- testa_logger (0.1.20)
10
+ testa_logger (0.1.21)
5
11
  activesupport
12
+ at_fork
6
13
  awesome_print
7
14
  aws-sdk-s3
8
15
  concurrent-ruby
@@ -21,7 +28,7 @@ GEM
21
28
  ast (2.4.2)
22
29
  awesome_print (1.9.2)
23
30
  aws-eventstream (1.2.0)
24
- aws-partitions (1.619.0)
31
+ aws-partitions (1.620.0)
25
32
  aws-sdk-core (3.132.0)
26
33
  aws-eventstream (~> 1, >= 1.0.2)
27
34
  aws-partitions (~> 1, >= 1.525.0)
@@ -76,6 +83,7 @@ PLATFORMS
76
83
  x86_64-linux
77
84
 
78
85
  DEPENDENCIES
86
+ at_fork!
79
87
  minitest (~> 5.0)
80
88
  rake (~> 12.0)
81
89
  rubocop (~> 1.26.0)
@@ -17,12 +17,12 @@ module TestaLogger
17
17
  @channel += "/#{logger.subgroup}" unless logger.subgroup.nil?
18
18
  @outbox = Concurrent::Array.new
19
19
  run_dispatch_thread
20
- at_exit { dispatch }
20
+ at_exit { dispatch if @outbox.count.positive? }
21
21
  end
22
22
 
23
23
  def push(level, time, tag, message, log)
24
24
  # after forking process, dispatch thread will stop working in the forked process
25
- run_dispatch_thread if @dispatch_thread.nil? || @dispatch_thread.status == false
25
+ run_dispatch_thread if @pid.nil? || @pid != Process.pid
26
26
 
27
27
  data = {
28
28
  app: logger.app,
@@ -38,6 +38,8 @@ module TestaLogger
38
38
  end
39
39
 
40
40
  def run_dispatch_thread
41
+ @pid = Process.pid
42
+
41
43
  @dispatch_thread = Thread.new do
42
44
  max_delay = 0.5
43
45
  max_buffer = 20
@@ -42,6 +42,7 @@ module TestaLogger
42
42
  setup_dispatcher
43
43
  start_write_thread
44
44
  init_s3_client if @options.persist
45
+ at_exit { flush_queue }
45
46
  end
46
47
 
47
48
  def create_log_file
@@ -65,17 +66,24 @@ module TestaLogger
65
66
  end
66
67
 
67
68
  def start_write_thread
69
+ @pid = Process.pid
68
70
  # we must use this queue in order to be able to collect logs in trap context
69
71
  @queue = Queue.new
70
72
  @write_thread = Thread.new do
71
- loop do
72
- text = @queue.pop
73
- Thread.stop if Thread.current["stop"]
74
- @log_device.write(text)
75
- end
73
+ loop { queue_pop }
76
74
  end
77
75
  end
78
76
 
77
+ def flush_queue
78
+ queue_pop while @queue.size.positive?
79
+ end
80
+
81
+ def queue_pop
82
+ text = @queue.pop
83
+ Thread.stop if Thread.current["stop"]
84
+ @log_device.write(text)
85
+ end
86
+
79
87
  def formatter
80
88
  options.formatter
81
89
  end
@@ -192,7 +200,7 @@ module TestaLogger
192
200
  log = format_message(formatted_severity, time, "", tag_and_message)
193
201
 
194
202
  # after forking process, write thread will stop working in the forked process
195
- start_write_thread if @write_thread.nil? || @write_thread.status == false
203
+ start_write_thread if @pid.nil? || @pid != Process.pid
196
204
  @queue << log
197
205
  @dispatcher.push(level, time, tag, message, log) if options.live
198
206
  return unless options.stdout
@@ -1,3 +1,3 @@
1
1
  module TestaLogger
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
3
3
  end
data/lib/testa_logger.rb CHANGED
@@ -9,6 +9,7 @@ require "concurrent-ruby"
9
9
  require "json"
10
10
  require "uri"
11
11
  require "net/http"
12
+ require "at_fork"
12
13
 
13
14
  module TestaLogger
14
15
  # @param [String] app name of the application, i.e. rails, ws, dj, filewatcher
data/logger.iml CHANGED
@@ -9,10 +9,11 @@
9
9
  <orderEntry type="sourceFolder" forTests="false" />
10
10
  <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.6.1, RVM: ruby-2.7.6) [gem]" level="application" />
11
11
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.6) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="at_fork (v0.0.1@b32ef8, RVM: ruby-2.7.6) [gem]" level="application" />
12
13
  <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.9.2, RVM: ruby-2.7.6) [gem]" level="application" />
13
14
  <orderEntry type="library" scope="PROVIDED" name="aws-eventstream (v1.2.0, RVM: ruby-2.7.6) [gem]" level="application" />
14
- <orderEntry type="library" scope="PROVIDED" name="aws-partitions (v1.614.0, RVM: ruby-2.7.6) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="aws-sdk-core (v3.131.5, RVM: ruby-2.7.6) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="aws-partitions (v1.619.0, RVM: ruby-2.7.6) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="aws-sdk-core (v3.132.0, RVM: ruby-2.7.6) [gem]" level="application" />
16
17
  <orderEntry type="library" scope="PROVIDED" name="aws-sdk-kms (v1.58.0, RVM: ruby-2.7.6) [gem]" level="application" />
17
18
  <orderEntry type="library" scope="PROVIDED" name="aws-sdk-s3 (v1.114.0, RVM: ruby-2.7.6) [gem]" level="application" />
18
19
  <orderEntry type="library" scope="PROVIDED" name="aws-sigv4 (v1.5.1, RVM: ruby-2.7.6) [gem]" level="application" />
@@ -42,21 +43,21 @@
42
43
  <option name="myRootTask">
43
44
  <RakeTaskImpl id="rake">
44
45
  <subtasks>
45
- <RakeTaskImpl description="Build testa_logger-0.1.6.gem into the pkg directory" fullCommand="build" id="build" />
46
+ <RakeTaskImpl description="Build testa_logger-0.1.20.gem into the pkg directory" fullCommand="build" id="build" />
46
47
  <RakeTaskImpl id="build">
47
48
  <subtasks>
48
- <RakeTaskImpl description="Generate SHA512 checksum if testa_logger-0.1.6.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
49
+ <RakeTaskImpl description="Generate SHA512 checksum if testa_logger-0.1.20.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
49
50
  </subtasks>
50
51
  </RakeTaskImpl>
51
52
  <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
52
53
  <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
53
- <RakeTaskImpl description="Build and install testa_logger-0.1.6.gem into system gems" fullCommand="install" id="install" />
54
+ <RakeTaskImpl description="Build and install testa_logger-0.1.20.gem into system gems" fullCommand="install" id="install" />
54
55
  <RakeTaskImpl id="install">
55
56
  <subtasks>
56
- <RakeTaskImpl description="Build and install testa_logger-0.1.6.gem into system gems without network access" fullCommand="install:local" id="local" />
57
+ <RakeTaskImpl description="Build and install testa_logger-0.1.20.gem into system gems without network access" fullCommand="install:local" id="local" />
57
58
  </subtasks>
58
59
  </RakeTaskImpl>
59
- <RakeTaskImpl description="Create tag v0.1.6 and build and push testa_logger-0.1.6.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
60
+ <RakeTaskImpl description="Create tag v0.1.20 and build and push testa_logger-0.1.20.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
60
61
  <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
61
62
  <RakeTaskImpl description="" fullCommand="default" id="default" />
62
63
  <RakeTaskImpl description="" fullCommand="release" id="release" />
data/testa_logger.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "concurrent-ruby"
25
25
  spec.add_runtime_dependency "json"
26
26
  spec.add_runtime_dependency "securerandom"
27
+ spec.add_runtime_dependency "at_fork"
27
28
 
28
29
  # Specify which files should be added to the gem when it is released.
29
30
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testa_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - karlo.razumovic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2022-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: at_fork
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Customized logger that can log while in trap context and broadcast logs
98
112
  to websocket
99
113
  email: