cpee-logging-xes-yaml 1.3.30 → 1.4.1
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 +4 -4
- data/cpee-logging-xes-yaml.gemspec +1 -1
- data/lib/cpee-logging-xes-yaml/logging.rb +14 -13
- data/lib/cpee-logging-xes-yaml/tools.rb +32 -21
- data/tools/cpee-logging-xes-yaml +49 -12
- data/tools/cpee-logging-xes-yaml-finder +56 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '093abf131db31464c118276deec2c33110a1eada1249b40451fca9eaeee3c38d'
|
|
4
|
+
data.tar.gz: 8ba44738e83d6d5487f33026012d9ee813bd4dada97d0e4d4ffeefa0b04494b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b20ebd080a36d9e71ea5e1bf1556d26c2e709fe28e9dd783058111dc4472bd52ecac7562d4e97a1c756a7768e29aec4f7aed4ec9cfeaf1df9e53a40d47e25a8
|
|
7
|
+
data.tar.gz: 958888e149af9efc14c16429830a3c54db0e97ac681826f08072a0e902ec036ae9369df8ae5b33599a8968f75fa70f774520e53f2e4429b8aca0923e90f65911
|
|
@@ -36,19 +36,20 @@ module CPEE
|
|
|
36
36
|
event_name = @p[2].value
|
|
37
37
|
payload = @p[3].value.read
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
### we do not write headers for now. Or else we can only do per instance sharding.
|
|
40
|
+
# unless File.exist? File.join(opts[:log_dir],@h['CPEE_INSTANCE_UUID'] + '.xes.yaml')
|
|
41
|
+
# notification = JSON.parse(payload)
|
|
42
|
+
# log = YAML::load(File.read(opts[:template]))
|
|
43
|
+
# log['log']['trace']['concept:name'] ||= notification['instance']
|
|
44
|
+
# log['log']['trace']['cpee:name'] ||= notification['instance-name'] if notification['instance-name']
|
|
45
|
+
# log['log']['trace']['cpee:instance'] ||= notification['instance-uuid']
|
|
46
|
+
# log['log']['trace']['cpee:parent_instance'] ||= notification.dig('content','attributes','parent_instance').to_i if notification.dig('content','attributes','parent_instance')
|
|
47
|
+
# log['log']['trace']['cpee:parent_instance_uuid'] ||= notification.dig('content','attributes','parent_instance_uuid') if notification.dig('content','attributes','parent_instance_uuid')
|
|
48
|
+
# log['log']['trace']['cpee:parent_instance_model'] ||= notification.dig('content','attributes','parent_instance_model') if notification.dig('content','attributes','parent_instance_model')
|
|
49
|
+
# log['log']['trace']['cpee:parent_instance_task_id'] ||= notification.dig('content','attributes','parent_instance_task_id') if notification.dig('content','attributes','parent_instance_task_id')
|
|
50
|
+
# log['log']['trace']['cpee:parent_instance_task_label'] ||= notification.dig('content','attributes','parent_instance_task_label') if notification.dig('content','attributes','parent_instance_task_label')
|
|
51
|
+
# File.open(File.join(opts[:log_dir],@h['CPEE_INSTANCE_UUID']+'.xes.yaml'),'w'){|f| f.puts log.to_yaml}
|
|
52
|
+
# end
|
|
52
53
|
|
|
53
54
|
EM.defer do
|
|
54
55
|
CPEE::Logging::forward opts, topic, event_name, payload
|
|
@@ -81,13 +81,15 @@ module CPEE
|
|
|
81
81
|
opts[:subscriptions].each do |e,urls|
|
|
82
82
|
if e == topic + '/' + event_name
|
|
83
83
|
urls.each do |url|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
EM.defer do
|
|
85
|
+
client = Riddl::Client.new(url)
|
|
86
|
+
client.post [
|
|
87
|
+
Riddl::Parameter::Simple::new('type','event'),
|
|
88
|
+
Riddl::Parameter::Simple::new('topic',topic),
|
|
89
|
+
Riddl::Parameter::Simple::new('event',event_name),
|
|
90
|
+
Riddl::Parameter::Complex::new('notification','application/json',payload)
|
|
91
|
+
]
|
|
92
|
+
end
|
|
91
93
|
end
|
|
92
94
|
end
|
|
93
95
|
end
|
|
@@ -150,7 +152,7 @@ module CPEE
|
|
|
150
152
|
ret[tid] = ret[tid][0]
|
|
151
153
|
end
|
|
152
154
|
hash = Digest::SHA1.hexdigest(ret[tid])
|
|
153
|
-
if !File.exist?(fname) ||
|
|
155
|
+
if !File.exist?(fname) || File.read(fname) != hash
|
|
154
156
|
File.write(fname,hash)
|
|
155
157
|
end
|
|
156
158
|
end
|
|
@@ -213,7 +215,7 @@ module CPEE
|
|
|
213
215
|
def self::load_values(where)
|
|
214
216
|
ret = nil
|
|
215
217
|
File.open(where,'r') do |f|
|
|
216
|
-
f.flock(File::
|
|
218
|
+
f.flock(File::LOCK_SH)
|
|
217
219
|
ret = JSON::load(f)
|
|
218
220
|
f.flock(File::LOCK_UN)
|
|
219
221
|
end
|
|
@@ -223,8 +225,6 @@ module CPEE
|
|
|
223
225
|
def self::forward(opts,topic,event_name,payload)
|
|
224
226
|
if topic == 'state' && event_name == 'change'
|
|
225
227
|
self::notify(opts,topic,event_name,payload)
|
|
226
|
-
elsif topic == 'state' && event_name == 'change'
|
|
227
|
-
self::notify(opts,topic,event_name,payload)
|
|
228
228
|
elsif topic == 'gateway' && event_name == 'join'
|
|
229
229
|
self::notify(opts,topic,event_name,payload)
|
|
230
230
|
end
|
|
@@ -236,7 +236,6 @@ module CPEE
|
|
|
236
236
|
return unless instance
|
|
237
237
|
|
|
238
238
|
log_dir = opts[:log_dir]
|
|
239
|
-
template = opts[:template]
|
|
240
239
|
|
|
241
240
|
instancenr = notification['instance']
|
|
242
241
|
content = notification['content']
|
|
@@ -250,7 +249,7 @@ module CPEE
|
|
|
250
249
|
if content['dslx']
|
|
251
250
|
CPEE::Logging::extract_probes(File.join(log_dir,instance),content['dslx'])
|
|
252
251
|
CPEE::Logging::extract_annotations(File.join(log_dir,instance),content['dslx']).each do |k,v|
|
|
253
|
-
so =
|
|
252
|
+
so = JSON.parse(notification.to_json)
|
|
254
253
|
so['content'].delete('dslx')
|
|
255
254
|
so['content'].delete('dsl')
|
|
256
255
|
so['content'].delete('description')
|
|
@@ -324,11 +323,17 @@ module CPEE
|
|
|
324
323
|
end
|
|
325
324
|
end
|
|
326
325
|
if event['stream:datastream'] && event['stream:datastream'].any?
|
|
327
|
-
notification['datastream'] = event['stream:datastream']
|
|
328
326
|
EM.defer do
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
327
|
+
self::notify(
|
|
328
|
+
opts,
|
|
329
|
+
'stream',
|
|
330
|
+
'extraction',
|
|
331
|
+
notification.merge(
|
|
332
|
+
'topic'=>'stream',
|
|
333
|
+
'name'=>'extraction',
|
|
334
|
+
'datastream'=>event['stream:datastream']
|
|
335
|
+
).to_json
|
|
336
|
+
)
|
|
332
337
|
end
|
|
333
338
|
end
|
|
334
339
|
end
|
|
@@ -362,11 +367,17 @@ module CPEE
|
|
|
362
367
|
File.open(File.join(log_dir,instance+'.xes.yaml'),'a') do |f|
|
|
363
368
|
f << {'event' => te}.to_yaml
|
|
364
369
|
end
|
|
365
|
-
notification['datastream'] = te['stream:datastream']
|
|
366
370
|
EM.defer do
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
371
|
+
self::notify(
|
|
372
|
+
opts,
|
|
373
|
+
'stream',
|
|
374
|
+
'extraction',
|
|
375
|
+
notification.merge(
|
|
376
|
+
'topic'=>'stream',
|
|
377
|
+
'name'=>'extraction',
|
|
378
|
+
'datastream'=>te['stream:datastream']
|
|
379
|
+
).to_json
|
|
380
|
+
)
|
|
370
381
|
end
|
|
371
382
|
end
|
|
372
383
|
end
|
data/tools/cpee-logging-xes-yaml
CHANGED
|
@@ -48,7 +48,7 @@ def wrap(s, width=78, indent=19, extra_indent=2)
|
|
|
48
48
|
return lines.join "\n"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
TEMPLATE_XES_XML_START = <<-END
|
|
52
52
|
<log xmlns="http://www.xes-standard.org/" xes.version="2.0" xes.features="nested-attributes">
|
|
53
53
|
<string key="creator" value="cpee.org"/>
|
|
54
54
|
<extension name="Time" prefix="time" uri="http://www.xes-standard.org/time.xesext"/>
|
|
@@ -70,7 +70,18 @@ TEMPLATE_XES_XML = <<-END
|
|
|
70
70
|
<string key="cpee:lifecycle:transition" value="activity/calling"/>
|
|
71
71
|
<date key="time:timestamp" value="__NOTSPECIFIED__"/>
|
|
72
72
|
</global>
|
|
73
|
-
|
|
73
|
+
END
|
|
74
|
+
TEMPLATE_XES_XML_TRC = <<-END
|
|
75
|
+
<trace xmlns="http://www.xes-standard.org/"/>
|
|
76
|
+
END
|
|
77
|
+
TEMPLATE_XES_XML_EVT = <<-END
|
|
78
|
+
<event xmlns="http://www.xes-standard.org/"/>
|
|
79
|
+
END
|
|
80
|
+
TEMPLATE_XES_XML_MID = <<-END
|
|
81
|
+
<trace>
|
|
82
|
+
END
|
|
83
|
+
TEMPLATE_XES_XML_END = <<-END
|
|
84
|
+
</trace>
|
|
74
85
|
</log>
|
|
75
86
|
END
|
|
76
87
|
|
|
@@ -86,16 +97,27 @@ def rec_type(it)
|
|
|
86
97
|
end
|
|
87
98
|
end
|
|
88
99
|
|
|
100
|
+
def format_secs(s)
|
|
101
|
+
return 'long' if s.infinite?
|
|
102
|
+
s = s.to_i
|
|
103
|
+
m = s / 60
|
|
104
|
+
m < 0 ? "#{s}s" : "#{'%02d' % m}m #{'%02d' % (s%60)}s"
|
|
105
|
+
end
|
|
106
|
+
|
|
89
107
|
def rec_a_insert(event,node,level=0)
|
|
90
108
|
event.each do |i|
|
|
91
109
|
tnode = node
|
|
92
110
|
case i
|
|
93
111
|
when Hash
|
|
112
|
+
tnode = node.add('x:list', 'key' => 'element')
|
|
94
113
|
rec_insert(i,tnode,level+1)
|
|
95
114
|
when Array
|
|
96
|
-
|
|
115
|
+
tnode = node.add('x:list', 'key' => 'element')
|
|
116
|
+
rec_insert(i,tnode,level+1)
|
|
97
117
|
when String
|
|
98
|
-
node.add(rec_type(i), 'key' =>
|
|
118
|
+
node.add(rec_type(i), 'key' => 'element', 'value' => (i.empty? ? "__UNSPECIFIED__" : i))
|
|
119
|
+
when Integer, Float
|
|
120
|
+
node.add(rec_type(i), 'key' => 'element', 'value' => i)
|
|
99
121
|
end
|
|
100
122
|
end
|
|
101
123
|
end
|
|
@@ -240,7 +262,7 @@ ARGV.options { |opt|
|
|
|
240
262
|
opt.on("--help", "-h", "This text") { puts opt; exit }
|
|
241
263
|
opt.on("--add [STRING]", "-a [STRING]", "Add attribute for extract-all and extract-last. Example: -a 'filter=me'") { |a| x,y = a.split('='); attr[x] = y }
|
|
242
264
|
opt.on("")
|
|
243
|
-
opt.on(wrap("\"#{exname}\" will be
|
|
265
|
+
opt.on(wrap("\"#{exname}\" will be called \"c\" in the examples for each command."))
|
|
244
266
|
exname = 'c'
|
|
245
267
|
opt.on("")
|
|
246
268
|
opt.on(wrap("new [DIR] scaffolds a sample logging service. Add a handler to a cpee instance to experience the pleasure."))
|
|
@@ -403,26 +425,41 @@ elsif command == 'to-xes-xml'
|
|
|
403
425
|
end
|
|
404
426
|
|
|
405
427
|
path.each do |f|
|
|
406
|
-
|
|
407
|
-
|
|
428
|
+
fname = File.basename(f,'.xes.yaml') + '.xes.xml'
|
|
429
|
+
File.write(fname,TEMPLATE_XES_XML_START)
|
|
408
430
|
|
|
409
431
|
io = File.open(f)
|
|
432
|
+
count = 1
|
|
433
|
+
start = Time.now
|
|
434
|
+
total = `grep -c -e '---' #{f}`.to_f
|
|
435
|
+
percent = 0
|
|
436
|
+
duration = 0
|
|
410
437
|
YAML.load_stream(io) do |e|
|
|
438
|
+
percent = count/total
|
|
439
|
+
diff = Time.now - start
|
|
440
|
+
duration = diff/percent
|
|
441
|
+
print "#{"%0#{Math.log10(total).to_i + 1}d" % count}/#{total.to_i} #{'%05.2f' % (percent*100)}% (#{format_secs(duration-diff)} left) \r" if (count % 1000) == 0
|
|
442
|
+
count += 1
|
|
411
443
|
if trace = e.dig('log','trace')
|
|
444
|
+
xml = XML::Smart.string(TEMPLATE_XES_XML_TRC)
|
|
445
|
+
xml.register_namespace 'x', 'http://www.xes-standard.org/'
|
|
412
446
|
trace.each do |t,tv|
|
|
413
447
|
xml.find('//x:trace').each do |ele|
|
|
414
448
|
ele.add('x:string', 'key' => t, 'value' => tv)
|
|
415
449
|
end
|
|
416
450
|
end
|
|
451
|
+
File.write(fname, ' ' + xml.root.dump.gsub(/\n/,"\n ") + "\n", mode: 'a')
|
|
452
|
+
File.write(fname, TEMPLATE_XES_XML_MID, mode: 'a')
|
|
417
453
|
end
|
|
418
454
|
if e.dig('event')
|
|
419
|
-
xml.
|
|
420
|
-
|
|
421
|
-
|
|
455
|
+
xml = XML::Smart.string(TEMPLATE_XES_XML_EVT)
|
|
456
|
+
xml.register_namespace 'x', 'http://www.xes-standard.org/'
|
|
457
|
+
rec_insert(e.dig('event'),xml.root)
|
|
458
|
+
File.write(fname, ' ' + xml.root.dump.gsub(/\n/,"\n ") + "\n", mode: 'a')
|
|
422
459
|
end
|
|
423
460
|
end
|
|
424
|
-
|
|
425
|
-
|
|
461
|
+
File.write(fname, TEMPLATE_XES_XML_END, mode: 'a')
|
|
462
|
+
puts "#{count}/#{total.to_i} 100% (took #{format_secs(duration)}) \n"
|
|
426
463
|
end
|
|
427
464
|
else
|
|
428
465
|
puts ARGV.options
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
#
|
|
3
|
+
# This file is part of CPEE-LOGGING-XES-YAML.
|
|
4
|
+
#
|
|
5
|
+
# CPEE-LOGGING-XES-YAML is free software: you can redistribute it and/or modify it
|
|
6
|
+
# under the terms of the GNU Lesser General Public License as published by the Free
|
|
7
|
+
# Software Foundation, either version 3 of the License, or (at your option) any
|
|
8
|
+
# later version.
|
|
9
|
+
#
|
|
10
|
+
# CPEE-LOGGING-XES-YAML is distributed in the hope that it will be useful, but
|
|
11
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
|
13
|
+
# more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along with
|
|
16
|
+
# CPEE-LOGGING-XES-YAML (file LICENSE in the main directory). If not, see
|
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
path = ARGV.shift()
|
|
20
|
+
lookup_lines = ARGV.shift().to_i()
|
|
21
|
+
regexes = ARGV
|
|
22
|
+
regexes.map!() { |el| el.gsub("\\n","\n") }
|
|
23
|
+
|
|
24
|
+
dir = Dir.open(File.join(path))
|
|
25
|
+
children = dir.children()
|
|
26
|
+
#pp children.length()
|
|
27
|
+
#pp children.filter() { |el| el.include?('.xes.yaml') }.length()
|
|
28
|
+
#pp children.filter() { |el| el.include?('.xes.shift.yaml') }.length()
|
|
29
|
+
#pp children.filter() { |el| el.include?('data.json') }.length()
|
|
30
|
+
#pp children.filter() { |el| el.include?('.anno') }.length()
|
|
31
|
+
#pp children.filter() { |el| el.include?('.probe') }.length()
|
|
32
|
+
#pp children.filter() { |el| el.include?('.branches.json') }.length()
|
|
33
|
+
#pp children.filter() { |el| el.include?('.shift.json') }.length()
|
|
34
|
+
children.filter!() { |el| el.end_with?('.xes.yaml') }
|
|
35
|
+
children.each() { |filename|
|
|
36
|
+
begin
|
|
37
|
+
file = File.open(File.join(path,filename))
|
|
38
|
+
lookup_lines.times() {
|
|
39
|
+
line = file.readline()
|
|
40
|
+
regexes.each() { |regex|
|
|
41
|
+
#pp regex
|
|
42
|
+
if(line.include?(regex)) then
|
|
43
|
+
puts "#{filename} matches '#{regex.gsub("\n","\\n")}' in line '#{line.gsub("\n","\\n")}' (file last modified: #{file.stat().mtime()})"
|
|
44
|
+
break
|
|
45
|
+
end
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
rescue Exception => e
|
|
49
|
+
#pp "Problem opening or reading file: #{e} -> go to next file"
|
|
50
|
+
#pp filename
|
|
51
|
+
next
|
|
52
|
+
ensure
|
|
53
|
+
file.close()
|
|
54
|
+
end
|
|
55
|
+
}
|
|
56
|
+
dir.close()
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cpee-logging-xes-yaml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juergen eTM Mangler
|
|
@@ -112,6 +112,7 @@ files:
|
|
|
112
112
|
- lib/cpee-logging-xes-yaml/topics.xml
|
|
113
113
|
- server/log
|
|
114
114
|
- tools/cpee-logging-xes-yaml
|
|
115
|
+
- tools/cpee-logging-xes-yaml-finder
|
|
115
116
|
homepage: http://cpee.org/
|
|
116
117
|
licenses:
|
|
117
118
|
- LGPL-3.0-or-later
|