babeltrace2 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/babeltrace2.gemspec +13 -0
- data/lib/babeltrace2.rb +49 -0
- data/lib/babeltrace2/error-reporting.rb +432 -0
- data/lib/babeltrace2/func-status.rb +26 -0
- data/lib/babeltrace2/graph/component-class-dev.rb +801 -0
- data/lib/babeltrace2/graph/component-class.rb +134 -0
- data/lib/babeltrace2/graph/component-descriptor-set.rb +78 -0
- data/lib/babeltrace2/graph/component.rb +362 -0
- data/lib/babeltrace2/graph/connection.rb +35 -0
- data/lib/babeltrace2/graph/graph.rb +523 -0
- data/lib/babeltrace2/graph/interrupter.rb +57 -0
- data/lib/babeltrace2/graph/message-iterator-class.rb +374 -0
- data/lib/babeltrace2/graph/message-iterator.rb +253 -0
- data/lib/babeltrace2/graph/message.rb +721 -0
- data/lib/babeltrace2/graph/port.rb +124 -0
- data/lib/babeltrace2/graph/private-query-executor.rb +4 -0
- data/lib/babeltrace2/graph/query-executor.rb +142 -0
- data/lib/babeltrace2/graph/self-component-class.rb +37 -0
- data/lib/babeltrace2/graph/self-component-port.rb +35 -0
- data/lib/babeltrace2/graph/self-component.rb +264 -0
- data/lib/babeltrace2/graph/self-message-iterator.rb +147 -0
- data/lib/babeltrace2/integer-range-set.rb +275 -0
- data/lib/babeltrace2/logging-defs.rb +19 -0
- data/lib/babeltrace2/logging.rb +77 -0
- data/lib/babeltrace2/plugin/plugin-dev.rb +335 -0
- data/lib/babeltrace2/plugin/plugin-loading.rb +459 -0
- data/lib/babeltrace2/trace-ir/clock-class.rb +258 -0
- data/lib/babeltrace2/trace-ir/clock-snapshot.rb +45 -0
- data/lib/babeltrace2/trace-ir/event-class.rb +292 -0
- data/lib/babeltrace2/trace-ir/event.rb +91 -0
- data/lib/babeltrace2/trace-ir/field-class.rb +1416 -0
- data/lib/babeltrace2/trace-ir/field-path.rb +123 -0
- data/lib/babeltrace2/trace-ir/field.rb +871 -0
- data/lib/babeltrace2/trace-ir/packet.rb +57 -0
- data/lib/babeltrace2/trace-ir/stream-class.rb +425 -0
- data/lib/babeltrace2/trace-ir/stream.rb +137 -0
- data/lib/babeltrace2/trace-ir/trace-class.rb +343 -0
- data/lib/babeltrace2/trace-ir/trace.rb +321 -0
- data/lib/babeltrace2/types.rb +667 -0
- data/lib/babeltrace2/util.rb +23 -0
- data/lib/babeltrace2/value.rb +869 -0
- data/lib/babeltrace2/version.rb +126 -0
- metadata +105 -0
@@ -0,0 +1,147 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
|
3
|
+
attach_function :bt_self_message_iterator_borrow_component,
|
4
|
+
[ :bt_self_message_iterator_handle ],
|
5
|
+
:bt_self_component_handle
|
6
|
+
|
7
|
+
attach_function :bt_self_message_iterator_borrow_port,
|
8
|
+
[ :bt_self_message_iterator_handle ],
|
9
|
+
:bt_self_component_port_output_handle
|
10
|
+
|
11
|
+
attach_function :bt_self_message_iterator_set_data,
|
12
|
+
[ :bt_self_message_iterator_handle, :pointer ],
|
13
|
+
:void
|
14
|
+
|
15
|
+
attach_function :bt_self_message_iterator_get_data,
|
16
|
+
[ :bt_self_message_iterator_handle ],
|
17
|
+
:pointer
|
18
|
+
|
19
|
+
attach_function :bt_self_message_iterator_is_interrupted,
|
20
|
+
[ :bt_self_message_iterator_handle ],
|
21
|
+
:bt_bool
|
22
|
+
|
23
|
+
class BTSelfMessageIterator < BTMessageIterator
|
24
|
+
def get_component
|
25
|
+
handle = Babeltrace2.bt_self_message_iterator_borrow_component(@handle)
|
26
|
+
BTSelfComponent.from_handle(handle)
|
27
|
+
end
|
28
|
+
alias component get_component
|
29
|
+
|
30
|
+
def get_port
|
31
|
+
handle = Babeltrace2.bt_self_message_iterator_borrow_port(@handle)
|
32
|
+
BTSelfComponentPortOutput.new(handle, retain: true)
|
33
|
+
end
|
34
|
+
alias port get_port
|
35
|
+
|
36
|
+
def set_data(user_data)
|
37
|
+
Babeltrace2.bt_self_message_iterator_set_data(@handle, user_data)
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def data=(user_data)
|
42
|
+
Babeltrace2.bt_self_message_iterator_set_data(@handle, user_data)
|
43
|
+
user_data
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_data
|
47
|
+
Babeltrace2.bt_self_message_iterator_get_data(@handle)
|
48
|
+
end
|
49
|
+
alias data get_data
|
50
|
+
|
51
|
+
def is_interrupted
|
52
|
+
Babeltrace2.bt_self_message_iterator_is_interrupted(@handle) != BT_FALSE
|
53
|
+
end
|
54
|
+
alias interrupted? is_interrupted
|
55
|
+
|
56
|
+
def create_message_stream_beginning(stream)
|
57
|
+
BTMessageStreamBeginning.new(self_message_iterator: @handle, stream: stream)
|
58
|
+
end
|
59
|
+
alias create_stream_beginning_message create_message_stream_beginning
|
60
|
+
alias create_stream_beginning create_message_stream_beginning
|
61
|
+
|
62
|
+
def create_message_stream_end(stream)
|
63
|
+
BTMessageStreamEnd.new(self_message_iterator: @handle, stream: stream)
|
64
|
+
end
|
65
|
+
alias create_stream_end_message create_message_stream_end
|
66
|
+
alias create_stream_end create_message_stream_end
|
67
|
+
|
68
|
+
def create_message_event(event_class, stream_or_packet, clock_snapshot_value: nil)
|
69
|
+
case stream_or_packet
|
70
|
+
when BTStream
|
71
|
+
stream = stream_or_packet
|
72
|
+
packet = nil
|
73
|
+
when BTPacket
|
74
|
+
stream = nil
|
75
|
+
packet = stream_or_packet
|
76
|
+
else
|
77
|
+
raise "invalid stream or packet"
|
78
|
+
end
|
79
|
+
BTMessageEvent.new(self_message_iterator: @handle, event_class: event_class,
|
80
|
+
stream: stream, clock_snapshot_value: clock_snapshot_value,
|
81
|
+
packet: packet)
|
82
|
+
end
|
83
|
+
alias create_event_message create_message_event
|
84
|
+
alias create_event create_message_event
|
85
|
+
|
86
|
+
def create_message_packet_beginning(packet, clock_snapshot_value: nil)
|
87
|
+
BTMessagePacketBeginning.new(self_message_iterator: @handle, packet: packet,
|
88
|
+
clock_snapshot_value: clock_snapshot_value)
|
89
|
+
end
|
90
|
+
alias create_packet_beginning_message create_message_packet_beginning
|
91
|
+
alias create_packet_beginning create_message_packet_beginning
|
92
|
+
|
93
|
+
def create_message_packet_end(packet, clock_snapshot_value: nil)
|
94
|
+
BTMessagePacketEnd.new(self_message_iterator: @handle, packet: packet,
|
95
|
+
clock_snapshot_value: clock_snapshot_value)
|
96
|
+
end
|
97
|
+
alias create_packet_end_message create_message_packet_end
|
98
|
+
alias create_packet_end create_message_packet_end
|
99
|
+
|
100
|
+
def create_message_discarded_events(stream, beginning_clock_snapshot_value: nil,
|
101
|
+
end_clock_snapshot_value: nil)
|
102
|
+
BTMessageDiscardedEvents.new(self_message_iterator: @handle, stream: stream,
|
103
|
+
beginning_clock_snapshot_value: beginning_clock_snapshot_value,
|
104
|
+
end_clock_snapshot_value: end_clock_snapshot_value)
|
105
|
+
end
|
106
|
+
alias create_discarded_events_message create_message_discarded_events
|
107
|
+
alias create_discarded_events create_message_discarded_events
|
108
|
+
|
109
|
+
def create_message_discarded_packets(stream, beginning_clock_snapshot_value: nil,
|
110
|
+
end_clock_snapshot_value: nil)
|
111
|
+
BTMessageDiscardedPackets.new(self_message_iterator: @handle, stream: stream,
|
112
|
+
beginning_clock_snapshot_value: beginning_clock_snapshot_value,
|
113
|
+
end_clock_snapshot_value: end_clock_snapshot_value)
|
114
|
+
end
|
115
|
+
alias create_discarded_packets_message create_message_discarded_packets
|
116
|
+
alias create_discarded_packets create_message_discarded_packets
|
117
|
+
|
118
|
+
def create_message_message_iterator_inactivity(clock_class, clock_snapshot_value)
|
119
|
+
BTMessageMessageIteratorInactivity.new(self_message_iterator: @handle,
|
120
|
+
clock_class: clock_class,
|
121
|
+
clock_snapshot_value: clock_snapshot_value)
|
122
|
+
end
|
123
|
+
alias create_message_iterator_inactivity_message create_message_message_iterator_inactivity
|
124
|
+
alias create_message_iterator_inactivity create_message_message_iterator_inactivity
|
125
|
+
end
|
126
|
+
|
127
|
+
attach_function :bt_self_message_iterator_configuration_set_can_seek_forward,
|
128
|
+
[ :bt_self_message_iterator_configuration_handle, :bt_bool ],
|
129
|
+
:void
|
130
|
+
|
131
|
+
class BTSelfMessageIterator
|
132
|
+
class Configuration < BTObject
|
133
|
+
def set_can_seek_forward(can_seek_forward)
|
134
|
+
Babeltrace2.bt_self_message_iterator_configuration_set_can_seek_forward(
|
135
|
+
@handle, can_seek_forward ? BT_TRUE : BT_FALSE)
|
136
|
+
self
|
137
|
+
end
|
138
|
+
|
139
|
+
def can_seek_forward=(can_seek_forward)
|
140
|
+
Babeltrace2.bt_self_message_iterator_configuration_set_can_seek_forward(
|
141
|
+
@handle, can_seek_forward ? BT_TRUE : BT_FALSE)
|
142
|
+
can_seek_forward
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
BTSelfMessageIteratorConfiguration = BTSelfMessageIterator::Configuration
|
147
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
|
3
|
+
attach_function :bt_integer_range_unsigned_get_lower,
|
4
|
+
[:bt_integer_range_unsigned_handle],
|
5
|
+
:uint64
|
6
|
+
|
7
|
+
attach_function :bt_integer_range_unsigned_get_upper,
|
8
|
+
[:bt_integer_range_unsigned_handle],
|
9
|
+
:uint64
|
10
|
+
|
11
|
+
attach_function :bt_integer_range_unsigned_is_equal,
|
12
|
+
[:bt_integer_range_unsigned_handle, :bt_integer_range_unsigned_handle],
|
13
|
+
:bt_bool
|
14
|
+
|
15
|
+
class BTIntegerRange < BTObject
|
16
|
+
def value
|
17
|
+
lower..upper
|
18
|
+
end
|
19
|
+
|
20
|
+
def include?(val)
|
21
|
+
lower <= val && upper >= val
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class BTIntegerRangeUnsigned < BTIntegerRange
|
26
|
+
def get_lower
|
27
|
+
Babeltrace2.bt_integer_range_unsigned_get_lower(@handle)
|
28
|
+
end
|
29
|
+
alias lower get_lower
|
30
|
+
alias min get_lower
|
31
|
+
|
32
|
+
def get_upper
|
33
|
+
Babeltrace2.bt_integer_range_unsigned_get_upper(@handle)
|
34
|
+
end
|
35
|
+
alias upper get_upper
|
36
|
+
alias max get_upper
|
37
|
+
|
38
|
+
def is_equal(other)
|
39
|
+
Babeltrace2.bt_integer_range_unsigned_is_equal(other) != BT_FALSE
|
40
|
+
end
|
41
|
+
alias == is_equal
|
42
|
+
end
|
43
|
+
|
44
|
+
attach_function :bt_integer_range_signed_get_lower,
|
45
|
+
[:bt_integer_range_signed_handle],
|
46
|
+
:int64
|
47
|
+
|
48
|
+
attach_function :bt_integer_range_signed_get_upper,
|
49
|
+
[:bt_integer_range_signed_handle],
|
50
|
+
:int64
|
51
|
+
|
52
|
+
attach_function :bt_integer_range_signed_is_equal,
|
53
|
+
[:bt_integer_range_signed_handle, :bt_integer_range_signed_handle],
|
54
|
+
:bt_bool
|
55
|
+
|
56
|
+
class BTIntegerRangeSigned < BTIntegerRange
|
57
|
+
def get_lower
|
58
|
+
Babeltrace2.bt_integer_range_signed_get_lower(@handle)
|
59
|
+
end
|
60
|
+
alias lower get_lower
|
61
|
+
|
62
|
+
def get_upper
|
63
|
+
Babeltrace2.bt_integer_range_signed_get_upper(@handle)
|
64
|
+
end
|
65
|
+
alias upper get_upper
|
66
|
+
|
67
|
+
def is_equal(other)
|
68
|
+
Babeltrace2.bt_integer_range_signed_is_equal(other) != BT_FALSE
|
69
|
+
end
|
70
|
+
alias == is_equal
|
71
|
+
end
|
72
|
+
|
73
|
+
BTIntegerRangeSetAddRangeStatus = enum :bt_integer_range_set_add_range_status,
|
74
|
+
[ :BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK, BT_FUNC_STATUS_OK,
|
75
|
+
:BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_MEMORY_ERROR, BT_FUNC_STATUS_MEMORY_ERROR]
|
76
|
+
|
77
|
+
attach_function :bt_integer_range_set_get_range_count,
|
78
|
+
[:bt_integer_range_set_handle],
|
79
|
+
:uint64
|
80
|
+
|
81
|
+
class BTIntegerRangeSet < BTSharedObject
|
82
|
+
AddRangeStatus = BTIntegerRangeSetAddRangeStatus
|
83
|
+
|
84
|
+
def self.from_value(value)
|
85
|
+
case value
|
86
|
+
when self
|
87
|
+
return value
|
88
|
+
when Array
|
89
|
+
range = self.new
|
90
|
+
range.push(*value)
|
91
|
+
else
|
92
|
+
range = self.new
|
93
|
+
range.add_range(value)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def get_range_count
|
98
|
+
return Babeltrace2.bt_integer_range_set_get_range_count(@handle)
|
99
|
+
end
|
100
|
+
alias range_count get_range_count
|
101
|
+
alias size get_range_count
|
102
|
+
|
103
|
+
def get_ranges
|
104
|
+
range_count.times.collect { |i|
|
105
|
+
get_range(i)
|
106
|
+
}
|
107
|
+
end
|
108
|
+
alias ranges get_ranges
|
109
|
+
alias to_a get_ranges
|
110
|
+
|
111
|
+
def push(*args)
|
112
|
+
args.each { |arg| add_range(arg) }
|
113
|
+
self
|
114
|
+
end
|
115
|
+
|
116
|
+
def each
|
117
|
+
if block_given?
|
118
|
+
range_count.times.each { |i|
|
119
|
+
yield get_range(i)
|
120
|
+
}
|
121
|
+
else
|
122
|
+
to_enum(:each)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def value
|
127
|
+
each.collect(&:value).to_a
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
def range_arg_get(lower, upper)
|
132
|
+
if not upper
|
133
|
+
case lower
|
134
|
+
when BTIntegerRange, Range, Array
|
135
|
+
upper = lower.max
|
136
|
+
lower = lower.min
|
137
|
+
else
|
138
|
+
upper = lower
|
139
|
+
end
|
140
|
+
end
|
141
|
+
[lower, upper]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
attach_function :bt_integer_range_set_unsigned_create,
|
146
|
+
[],
|
147
|
+
:bt_integer_range_set_unsigned_handle
|
148
|
+
|
149
|
+
attach_function :bt_integer_range_set_unsigned_add_range,
|
150
|
+
[:bt_integer_range_set_unsigned_handle, :uint64, :uint64],
|
151
|
+
:bt_integer_range_set_add_range_status
|
152
|
+
|
153
|
+
attach_function :bt_integer_range_set_unsigned_borrow_range_by_index_const,
|
154
|
+
[:bt_integer_range_set_unsigned_handle, :uint64],
|
155
|
+
:bt_integer_range_unsigned_handle
|
156
|
+
|
157
|
+
attach_function :bt_integer_range_set_unsigned_is_equal,
|
158
|
+
[:bt_integer_range_set_unsigned_handle, :bt_integer_range_set_unsigned_handle],
|
159
|
+
:bt_bool
|
160
|
+
|
161
|
+
attach_function :bt_integer_range_set_unsigned_get_ref,
|
162
|
+
[:bt_integer_range_set_unsigned_handle],
|
163
|
+
:void
|
164
|
+
|
165
|
+
attach_function :bt_integer_range_set_unsigned_put_ref,
|
166
|
+
[:bt_integer_range_set_unsigned_handle],
|
167
|
+
:void
|
168
|
+
|
169
|
+
class BTIntegerRangeSet
|
170
|
+
class Unsigned < BTIntegerRangeSet
|
171
|
+
@get_ref = :bt_integer_range_set_unsigned_get_ref
|
172
|
+
@put_ref = :bt_integer_range_set_unsigned_put_ref
|
173
|
+
|
174
|
+
def initialize(handle = nil, retain: true, auto_release: true)
|
175
|
+
if handle
|
176
|
+
super(handle, retain: retain, auto_release: auto_release)
|
177
|
+
else
|
178
|
+
handle = Babeltrace2.bt_integer_range_set_unsigned_create()
|
179
|
+
raise Babeltrace2.process_error if handle.null?
|
180
|
+
super(handle)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def add_range(lower, upper = nil)
|
185
|
+
res = Babeltrace2.bt_integer_range_set_unsigned_add_range(
|
186
|
+
@handle, *range_arg_get(lower, upper))
|
187
|
+
raise Babeltrace2.process_error(res) if res != :BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK
|
188
|
+
self
|
189
|
+
end
|
190
|
+
alias add add_range
|
191
|
+
|
192
|
+
def get_range(index)
|
193
|
+
count = range_count
|
194
|
+
index += count if count < 0
|
195
|
+
return nil if index >= count || index < 0
|
196
|
+
BTIntegerRangeUnsigned.new(
|
197
|
+
Babeltrace2.bt_integer_range_set_unsigned_borrow_range_by_index_const(
|
198
|
+
@handle, index))
|
199
|
+
end
|
200
|
+
alias [] get_range
|
201
|
+
|
202
|
+
def is_equal(other)
|
203
|
+
Babeltrace2.bt_integer_range_set_unsigned_is_equal(@handle, other) != BT_FALSE
|
204
|
+
end
|
205
|
+
alias == is_equal
|
206
|
+
end
|
207
|
+
end
|
208
|
+
BTIntegerRangeSetUnsigned = BTIntegerRangeSet::Unsigned
|
209
|
+
|
210
|
+
attach_function :bt_integer_range_set_signed_create,
|
211
|
+
[],
|
212
|
+
:bt_integer_range_set_signed_handle
|
213
|
+
|
214
|
+
attach_function :bt_integer_range_set_signed_add_range,
|
215
|
+
[:bt_integer_range_set_signed_handle, :int64, :int64],
|
216
|
+
:bt_integer_range_set_add_range_status
|
217
|
+
|
218
|
+
attach_function :bt_integer_range_set_signed_borrow_range_by_index_const,
|
219
|
+
[:bt_integer_range_set_signed_handle, :uint64],
|
220
|
+
:bt_integer_range_signed_handle
|
221
|
+
|
222
|
+
attach_function :bt_integer_range_set_signed_is_equal,
|
223
|
+
[:bt_integer_range_set_signed_handle, :bt_integer_range_set_signed_handle],
|
224
|
+
:bt_bool
|
225
|
+
|
226
|
+
attach_function :bt_integer_range_set_signed_get_ref,
|
227
|
+
[:bt_integer_range_set_signed_handle],
|
228
|
+
:void
|
229
|
+
|
230
|
+
attach_function :bt_integer_range_set_signed_put_ref,
|
231
|
+
[:bt_integer_range_set_signed_handle],
|
232
|
+
:void
|
233
|
+
|
234
|
+
class BTIntegerRangeSet
|
235
|
+
class Signed < BTIntegerRangeSet
|
236
|
+
@get_ref = :bt_integer_range_set_signed_get_ref
|
237
|
+
@put_ref = :bt_integer_range_set_signed_put_ref
|
238
|
+
|
239
|
+
def initialize(handle = nil, retain: true, auto_release: true)
|
240
|
+
if handle
|
241
|
+
super(handle, retain: retain, auto_release: auto_release)
|
242
|
+
else
|
243
|
+
handle = Babeltrace2.bt_integer_range_set_signed_create()
|
244
|
+
raise Babeltrace2.process_error if handle.null?
|
245
|
+
super(handle)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def add_range(lower, upper = nil)
|
250
|
+
res = Babeltrace2.bt_integer_range_set_signed_add_range(
|
251
|
+
@handle, *range_arg_get(lower, upper))
|
252
|
+
raise Babeltrace2.process_error(res) if res != :BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_OK
|
253
|
+
self
|
254
|
+
end
|
255
|
+
alias add add_range
|
256
|
+
|
257
|
+
def get_range(index)
|
258
|
+
count = range_count
|
259
|
+
index += count if count < 0
|
260
|
+
return nil if index >= count || index < 0
|
261
|
+
BTIntegerRangeSigned.new(
|
262
|
+
Babeltrace2.bt_integer_range_set_signed_borrow_range_by_index_const(
|
263
|
+
@handle, index))
|
264
|
+
end
|
265
|
+
alias [] get_range
|
266
|
+
|
267
|
+
def is_equal(other)
|
268
|
+
Babeltrace2.bt_integer_range_set_signed_is_equal(@handle, other) != BT_FALSE
|
269
|
+
end
|
270
|
+
alias == is_equal
|
271
|
+
end
|
272
|
+
end
|
273
|
+
BTIntegerRangeSetSigned = BTIntegerRangeSet::Signed
|
274
|
+
|
275
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
|
3
|
+
BT_LOGGING_LEVEL_TRACE = 1
|
4
|
+
private_constant :BT_LOGGING_LEVEL_TRACE
|
5
|
+
BT_LOGGING_LEVEL_DEBUG = 2
|
6
|
+
private_constant :BT_LOGGING_LEVEL_DEBUG
|
7
|
+
BT_LOGGING_LEVEL_INFO = 3
|
8
|
+
private_constant :BT_LOGGING_LEVEL_INFO
|
9
|
+
BT_LOGGING_LEVEL_WARNING = 4
|
10
|
+
private_constant :BT_LOGGING_LEVEL_WARNING
|
11
|
+
BT_LOGGING_LEVEL_ERROR = 5
|
12
|
+
private_constant :BT_LOGGING_LEVEL_ERROR
|
13
|
+
BT_LOGGING_LEVEL_FATAL = 6
|
14
|
+
private_constant :BT_LOGGING_LEVEL_FATAL
|
15
|
+
BT_LOGGING_LEVEL_NONE = 0xff
|
16
|
+
private_constant :BT_LOGGING_LEVEL_NONE
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Babeltrace2
|
2
|
+
BTLoggingLevel = enum :bt_logging_level,
|
3
|
+
[ :BT_LOGGING_LEVEL_TRACE, BT_LOGGING_LEVEL_TRACE,
|
4
|
+
:BT_LOGGING_LEVEL_DEBUG, BT_LOGGING_LEVEL_DEBUG,
|
5
|
+
:BT_LOGGING_LEVEL_INFO, BT_LOGGING_LEVEL_INFO,
|
6
|
+
:BT_LOGGING_LEVEL_WARNING, BT_LOGGING_LEVEL_WARNING,
|
7
|
+
:BT_LOGGING_LEVEL_ERROR, BT_LOGGING_LEVEL_ERROR,
|
8
|
+
:BT_LOGGING_LEVEL_FATAL, BT_LOGGING_LEVEL_FATAL,
|
9
|
+
:BT_LOGGING_LEVEL_NONE, BT_LOGGING_LEVEL_NONE ]
|
10
|
+
|
11
|
+
attach_function :bt_logging_set_global_level,
|
12
|
+
[:bt_logging_level],
|
13
|
+
:void
|
14
|
+
|
15
|
+
attach_function :bt_logging_get_global_level,
|
16
|
+
[],
|
17
|
+
:bt_logging_level
|
18
|
+
|
19
|
+
attach_function :bt_logging_get_minimal_level,
|
20
|
+
[],
|
21
|
+
:bt_logging_level
|
22
|
+
|
23
|
+
module BTLogging
|
24
|
+
class << self
|
25
|
+
def set_global_level(logging_level)
|
26
|
+
Babeltrace2.bt_logging_set_global_level(logging_level)
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def global_level=(logging_level)
|
31
|
+
set_global_level(logging_level)
|
32
|
+
logging_level
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_global_level
|
36
|
+
Babeltrace2.bt_logging_get_global_level
|
37
|
+
end
|
38
|
+
alias global_level get_global_level
|
39
|
+
|
40
|
+
def get_minimal_level
|
41
|
+
Babeltrace2.bt_logging_get_minimal_level
|
42
|
+
end
|
43
|
+
alias minimal_level get_minimal_level
|
44
|
+
|
45
|
+
def get_default_level
|
46
|
+
if ENV["BABELTRACE_RUBY_BT2_LOG_LEVEL"]
|
47
|
+
get_level_from_string(ENV["BABELTRACE_RUBY_BT2_LOG_LEVEL"])
|
48
|
+
else
|
49
|
+
get_global_level
|
50
|
+
end
|
51
|
+
end
|
52
|
+
alias default_level get_default_level
|
53
|
+
|
54
|
+
private
|
55
|
+
def get_level_from_string(str)
|
56
|
+
case str
|
57
|
+
when "TRACE", "T"
|
58
|
+
:BT_LOGGING_LEVEL_TRACE
|
59
|
+
when "DEBUG", "D"
|
60
|
+
:BT_LOGGING_LEVEL_DEBUG
|
61
|
+
when "INFO", "I"
|
62
|
+
:BT_LOGGING_LEVEL_INFO
|
63
|
+
when "WARN", "WARNING", "W"
|
64
|
+
:BT_LOGGING_LEVEL_WARNING
|
65
|
+
when "ERROR", "E"
|
66
|
+
:BT_LOGGING_LEVEL_ERROR
|
67
|
+
when "FATAL", "F"
|
68
|
+
:BT_LOGGING_LEVEL_FATAL
|
69
|
+
when "NONE", "N"
|
70
|
+
:BT_LOGGING_LEVEL_NONE
|
71
|
+
else
|
72
|
+
-1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|