akita-har_logger 0.2.11 → 0.2.12

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: 95fc4c3e51ec19663e862655884702fdcc42aa567f0ca706f1b2dfda065662e5
4
- data.tar.gz: 04c93b6cc55669bec6b303803928d1c28bd44aa770a7f4b88763cb430f7f7d90
3
+ metadata.gz: 804312155d41d0e753f3b4e527fff9140fbd82ef27b9bda45a726e0ca52baea6
4
+ data.tar.gz: 8407df19c1bdbd64a432bf93b6ff0c22bf1c48a647832ede28d7fde6fb37fb0d
5
5
  SHA512:
6
- metadata.gz: f76e965199fff57f90f321c3293b6c8447ac1fbfec7d5987ef5bc7e005aa98527d34c33d79f92ff964267b086208d121ad0d25774a19c00f2dbea9455eaf40ab
7
- data.tar.gz: 287cc1c7f0eb46932b224764171f26612e406afc2d388ee30d5c238000349161741c14afb9def65af27d2703c5ac1c908763241e07e35f269ae1b064a6b8d922
6
+ metadata.gz: f4d42e38b8e5a1eb510a5d6ac6866a8455528306c063cfbfa9c97b7c38706096c38554d795fa78b723c64bf003b65ab6759645a63b7567a1f3b545df4915f283
7
+ data.tar.gz: ebe6c4aecfc66a61d8b68e807f07a51155f0b17e26054fac35aca1b5924f1bec38e9aebf74d6364fb78b4c1822ed4ce712cb41006779676cd210a60bd7ce8472
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akita-har_logger (0.2.11)
4
+ akita-har_logger (0.2.12)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -138,13 +138,23 @@ module Akita
138
138
  # queue.
139
139
  def self.get_queue(out_file_name)
140
140
  queue = nil
141
+ Rails.logger.debug "AKITA: About to acquire entry-queue mutex "\
142
+ "#{@@entry_queues_mutex} in #{Thread.current}. "\
143
+ "Self-owned? #{@@entry_queues_mutex.owned?}"
141
144
  @@entry_queues_mutex.synchronize {
142
- if @@entry_queues.has_key?(out_file_name) then
143
- return @@entry_queues[out_file_name]
145
+ begin
146
+ Rails.logger.debug "AKITA: Acquired entry-queue mutex "\
147
+ "#{@@entry_queues_mutex} in #{Thread.current}."
148
+ if @@entry_queues.has_key?(out_file_name) then
149
+ return @@entry_queues[out_file_name]
150
+ end
151
+
152
+ queue = Queue.new
153
+ @@entry_queues[out_file_name] = queue
154
+ ensure
155
+ Rails.logger.debug "AKITA: About to release entry-queue mutex "\
156
+ "#{@@entry_queues_mutex} in #{Thread.current}."
144
157
  end
145
-
146
- queue = Queue.new
147
- @@entry_queues[out_file_name] = queue
148
158
  }
149
159
 
150
160
  WriterThread.new out_file_name, queue
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Akita
4
4
  module HarLogger
5
- VERSION = "0.2.11"
5
+ VERSION = "0.2.12"
6
6
  end
7
7
  end
@@ -15,42 +15,57 @@ module Akita
15
15
  shutdown_mutex = Mutex.new
16
16
 
17
17
  Thread.new do
18
+ Rails.logger.debug "AKITA: About to acquire shutdown mutex "\
19
+ "#{shutdown_mutex} for file #{out_file_name} "\
20
+ "in writer thread #{Thread.current}. "\
21
+ "Self-owned? #{shutdown_mutex.owned?}"
18
22
  shutdown_mutex.synchronize {
19
- File.open(out_file_name, 'w') { |f|
20
- # Produce a preamble.
21
- f.write <<~EOF.chomp
22
- {
23
- "log": {
24
- "version": "1.2",
25
- "creator": {
26
- "name": "Akita HAR logger for Ruby",
27
- "version": "1.0.0"
28
- },
29
- "entries": [
30
- EOF
23
+ begin
24
+ Rails.logger.debug "AKITA: Acquired shutdown mutex "\
25
+ "#{shutdown_mutex} for file "\
26
+ "#{out_file_name} in writer thread "\
27
+ "#{Thread.current}."
28
+ File.open(out_file_name, 'w') { |f|
29
+ # Produce a preamble.
30
+ f.write <<~EOF.chomp
31
+ {
32
+ "log": {
33
+ "version": "1.2",
34
+ "creator": {
35
+ "name": "Akita HAR logger for Ruby",
36
+ "version": "1.0.0"
37
+ },
38
+ "entries": [
39
+ EOF
31
40
 
32
- first_entry = true
41
+ first_entry = true
33
42
 
34
- loop do
35
- entry = entry_queue.pop
36
- if entry == nil then break end
43
+ loop do
44
+ entry = entry_queue.pop
45
+ if entry == nil then break end
37
46
 
38
- # Emit comma separator if needed.
39
- f.puts (first_entry ? '' : ',')
40
- first_entry = false
47
+ # Emit comma separator if needed.
48
+ f.puts (first_entry ? '' : ',')
49
+ first_entry = false
41
50
 
42
- # Emit the dequeued entry.
43
- f.write JSON.generate(entry)
44
- end
51
+ # Emit the dequeued entry.
52
+ f.write JSON.generate(entry)
53
+ end
45
54
 
46
- # Produce the epilogue.
47
- f.write <<~EOF
55
+ # Produce the epilogue.
56
+ f.write <<~EOF
48
57
 
49
- ]
58
+ ]
59
+ }
50
60
  }
51
- }
52
- EOF
53
- }
61
+ EOF
62
+ }
63
+ ensure
64
+ Rails.logger.debug "AKITA: About to release shutdown mutex "\
65
+ "#{shutdown_mutex} for file "\
66
+ "#{out_file_name} in writer thread "\
67
+ "#{Thread.current}."
68
+ end
54
69
  }
55
70
  end
56
71
 
@@ -59,7 +74,18 @@ module Akita
59
74
  # Signal to the consumer that this is the end of the entry stream and
60
75
  # wait for the consumer to terminate.
61
76
  entry_queue << nil
62
- shutdown_mutex.synchronize {}
77
+ Rails.logger.debug "AKITA: About to acquire shutdown mutex "\
78
+ "#{shutdown_mutex} for file #{out_file_name} "\
79
+ "while shutting down in #{Thread.current}. "\
80
+ "Self-owned? #{shutdown_mutex.owned?}"
81
+ shutdown_mutex.synchronize {
82
+ Rails.logger.debug "AKITA: Acquired shutdown mutex "\
83
+ "#{shutdown_mutex} for file #{out_file_name} "\
84
+ "while shutting down in #{Thread.current}."
85
+ Rails.logger.debug "AKITA: About to release shutdown mutex "\
86
+ "#{shutdown_mutex} for file #{out_file_name} "\
87
+ "while shutting down in #{Thread.current}."
88
+ }
63
89
  end
64
90
  end
65
91
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akita-har_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jed Liu