testa_logger 0.1.19 → 0.1.22

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: 307ec423100fc91b076c4a0b74f4e21f3bad229f0229d5590f422026bc2559ff
4
- data.tar.gz: cfb7daddd00e39662ec98eb0ceb70251b984db573067f8d9ad0b3d050c06d161
3
+ metadata.gz: ff7ad4e5fb128b752065e10155a436d3c897561744f985bc671a65a1b92f2a50
4
+ data.tar.gz: 672aa0754bde18448acc847ca3e5d82f63ed4bca7c1cfad6e9d697d978c283a0
5
5
  SHA512:
6
- metadata.gz: '019210822fcf3b11855ea4baeb121d105f4c3f411cd2367b09fe7ce5e7beb48da099a7346cc9f7b910e314534cac5fafc41e051e704ab6e70bac58ed2538da9c'
7
- data.tar.gz: de1d807516efb2e4d94934dbe1527ef0cc339599cb6644405b73f44ac8dd3a9a3d63e1cfcec470931bc0d45c495a03ecfc8a922636f54c774957d2bb7e37c0fa
6
+ metadata.gz: 504beb57cb3a52a14f60643b6ee9e51ce5d1e59282d248ccf9714229bf1f4de252262ebd07215f7e7b3a0f3d7a4e6ec3595fb241188c75de1d461493d2aa9f11
7
+ data.tar.gz: 989341c9df47cfcc9c7eecc6159a4a0288b258b6384f049b3801b99d0758cefbdf4b9cded7e8d398ea0b03fc3720b0f79ac518cd9d146f358f97c90d13b7bb3d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testa_logger (0.1.19)
4
+ testa_logger (0.1.22)
5
5
  activesupport
6
6
  awesome_print
7
7
  aws-sdk-s3
@@ -21,8 +21,8 @@ GEM
21
21
  ast (2.4.2)
22
22
  awesome_print (1.9.2)
23
23
  aws-eventstream (1.2.0)
24
- aws-partitions (1.614.0)
25
- aws-sdk-core (3.131.5)
24
+ aws-partitions (1.620.0)
25
+ aws-sdk-core (3.132.0)
26
26
  aws-eventstream (~> 1, >= 1.0.2)
27
27
  aws-partitions (~> 1, >= 1.525.0)
28
28
  aws-sigv4 (~> 1.1)
@@ -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,15 +200,15 @@ 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
199
207
 
200
208
  if level >= ERROR
201
- warn log
209
+ $stderr.puts(log) # rubocop:disable Style/StderrPuts
202
210
  else
203
- puts log
211
+ $stdout.puts(log)
204
212
  end
205
213
  end
206
214
 
@@ -1,3 +1,3 @@
1
1
  module TestaLogger
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.22"
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
@@ -11,8 +11,8 @@
11
11
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.6) [gem]" level="application" />
12
12
  <orderEntry type="library" scope="PROVIDED" name="awesome_print (v1.9.2, RVM: ruby-2.7.6) [gem]" level="application" />
13
13
  <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" />
14
+ <orderEntry type="library" scope="PROVIDED" name="aws-partitions (v1.620.0, RVM: ruby-2.7.6) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="aws-sdk-core (v3.132.0, RVM: ruby-2.7.6) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="aws-sdk-kms (v1.58.0, RVM: ruby-2.7.6) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="aws-sdk-s3 (v1.114.0, RVM: ruby-2.7.6) [gem]" level="application" />
18
18
  <orderEntry type="library" scope="PROVIDED" name="aws-sigv4 (v1.5.1, RVM: ruby-2.7.6) [gem]" level="application" />
@@ -42,21 +42,21 @@
42
42
  <option name="myRootTask">
43
43
  <RakeTaskImpl id="rake">
44
44
  <subtasks>
45
- <RakeTaskImpl description="Build testa_logger-0.1.6.gem into the pkg directory" fullCommand="build" id="build" />
45
+ <RakeTaskImpl description="Build testa_logger-0.1.21.gem into the pkg directory" fullCommand="build" id="build" />
46
46
  <RakeTaskImpl id="build">
47
47
  <subtasks>
48
- <RakeTaskImpl description="Generate SHA512 checksum if testa_logger-0.1.6.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
48
+ <RakeTaskImpl description="Generate SHA512 checksum if testa_logger-0.1.21.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
49
49
  </subtasks>
50
50
  </RakeTaskImpl>
51
51
  <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
52
52
  <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" />
53
+ <RakeTaskImpl description="Build and install testa_logger-0.1.21.gem into system gems" fullCommand="install" id="install" />
54
54
  <RakeTaskImpl id="install">
55
55
  <subtasks>
56
- <RakeTaskImpl description="Build and install testa_logger-0.1.6.gem into system gems without network access" fullCommand="install:local" id="local" />
56
+ <RakeTaskImpl description="Build and install testa_logger-0.1.21.gem into system gems without network access" fullCommand="install:local" id="local" />
57
57
  </subtasks>
58
58
  </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]" />
59
+ <RakeTaskImpl description="Create tag v0.1.21 and build and push testa_logger-0.1.21.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
60
60
  <RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
61
61
  <RakeTaskImpl description="" fullCommand="default" id="default" />
62
62
  <RakeTaskImpl description="" fullCommand="release" id="release" />
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.19
4
+ version: 0.1.22
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-18 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