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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/akita/har_logger.rb +15 -5
- data/lib/akita/har_logger/version.rb +1 -1
- data/lib/akita/har_logger/writer_thread.rb +55 -29
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 804312155d41d0e753f3b4e527fff9140fbd82ef27b9bda45a726e0ca52baea6
|
4
|
+
data.tar.gz: 8407df19c1bdbd64a432bf93b6ff0c22bf1c48a647832ede28d7fde6fb37fb0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4d42e38b8e5a1eb510a5d6ac6866a8455528306c063cfbfa9c97b7c38706096c38554d795fa78b723c64bf003b65ab6759645a63b7567a1f3b545df4915f283
|
7
|
+
data.tar.gz: ebe6c4aecfc66a61d8b68e807f07a51155f0b17e26054fac35aca1b5924f1bec38e9aebf74d6364fb78b4c1822ed4ce712cb41006779676cd210a60bd7ce8472
|
data/Gemfile.lock
CHANGED
data/lib/akita/har_logger.rb
CHANGED
@@ -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
|
-
|
143
|
-
|
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
|
@@ -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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
41
|
+
first_entry = true
|
33
42
|
|
34
|
-
|
35
|
-
|
36
|
-
|
43
|
+
loop do
|
44
|
+
entry = entry_queue.pop
|
45
|
+
if entry == nil then break end
|
37
46
|
|
38
|
-
|
39
|
-
|
40
|
-
|
47
|
+
# Emit comma separator if needed.
|
48
|
+
f.puts (first_entry ? '' : ',')
|
49
|
+
first_entry = false
|
41
50
|
|
42
|
-
|
43
|
-
|
44
|
-
|
51
|
+
# Emit the dequeued entry.
|
52
|
+
f.write JSON.generate(entry)
|
53
|
+
end
|
45
54
|
|
46
|
-
|
47
|
-
|
55
|
+
# Produce the epilogue.
|
56
|
+
f.write <<~EOF
|
48
57
|
|
49
|
-
|
58
|
+
]
|
59
|
+
}
|
50
60
|
}
|
51
|
-
|
52
|
-
|
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
|
-
|
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
|