testa_logger 0.1.20 → 0.1.23

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: 1fc3283c9e219fa0df7fa94523a6c71d5078095137b40605cf7a28c6c775a67d
4
+ data.tar.gz: 3bd3c773dc957103999ccc809c562b8fc4ef22600a643411d12f393d2a2b31f7
5
5
  SHA512:
6
- metadata.gz: 6f64334d97044c3fc3d5851c73453d1819b78ab447ae6d7a4e9f995ca64a518bd2b781d0611278fc0a0315f51729ae76ab975a93e3b204d17586c964d39ad85e
7
- data.tar.gz: 40523364197a2e26399011dd6720e972c4cc586ba63fe96fa21eee42ebd0ca6adc7c0b794245e957fc3d8256310179258e4bde3435f186cae200db94eb0652e7
6
+ metadata.gz: a6f72724334e8d75e0a9dbcbaa1de87afd25c0f203b6e60c7656e0cfcafab5e040dead005eab6e2055d68a9712d376ba0ee9fe389ca07ceab1f5f4cefa3133cf
7
+ data.tar.gz: 65f0fb6dc5f8147167172a97ed046ab6847904cc631b7fade48172e3e637eaaaac0534e75bb2417614b32e7d7b90f957870a90553d7c53c54862f50745b50618
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- testa_logger (0.1.20)
4
+ testa_logger (0.1.23)
5
5
  activesupport
6
6
  awesome_print
7
7
  aws-sdk-s3
@@ -21,7 +21,7 @@ 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.619.0)
24
+ aws-partitions (1.620.0)
25
25
  aws-sdk-core (3.132.0)
26
26
  aws-eventstream (~> 1, >= 1.0.2)
27
27
  aws-partitions (~> 1, >= 1.525.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.23"
3
3
  end
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.22.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.22.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.22.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.22.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.22 and build and push testa_logger-0.1.22.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.20
4
+ version: 0.1.23
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