pangdudu-rofl 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rofl.rb +12 -11
- data/lib/rofl_trace.rb +9 -0
- data/lib/test_rofl.rb +1 -1
- metadata +1 -1
data/lib/rofl.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'logger'
|
2
|
-
|
2
|
+
require 'rofl_trace'
|
3
3
|
#little happy logger module
|
4
4
|
module Rofl
|
5
|
+
include RoflTrace
|
5
6
|
|
6
7
|
attr_accessor :debugname,:logger
|
7
8
|
|
@@ -17,39 +18,39 @@ module Rofl
|
|
17
18
|
@tracing = false
|
18
19
|
#enable tracing
|
19
20
|
if @tracing
|
20
|
-
|
21
|
-
include RoflTrace
|
22
|
-
rofl_enable_trace
|
21
|
+
rofl_enable_silent_trace
|
23
22
|
end
|
24
23
|
end
|
25
24
|
end
|
26
25
|
#error message
|
27
26
|
def elog text="error"
|
28
27
|
rofl_logger_check #check if logger is setup
|
29
|
-
@logger.error "#{@debugname}.#{rofl_meth_trace}: #{text.to_s}"
|
28
|
+
@logger.error "#{@debugname}.#{rofl_meth_trace.to_s}: #{text.to_s}"
|
30
29
|
end
|
31
30
|
#warning
|
32
31
|
def wlog text="warning"
|
33
32
|
rofl_logger_check #check if logger is setup
|
34
|
-
@logger.warning "#{@debugname}.#{rofl_meth_trace}: #{text.to_s}"
|
33
|
+
@logger.warning "#{@debugname}.#{rofl_meth_trace.to_s}: #{text.to_s}"
|
35
34
|
end
|
36
35
|
#info message
|
37
36
|
def ilog text="info"
|
38
37
|
rofl_logger_check #check if logger is setup
|
39
|
-
@logger.info "#{@debugname}.#{rofl_meth_trace}: #{text.to_s}"
|
38
|
+
@logger.info "#{@debugname}.#{rofl_meth_trace.to_s}: #{text.to_s}"
|
40
39
|
end
|
41
40
|
#debug message
|
42
41
|
def dlog text="debug"
|
43
42
|
rofl_logger_check #check if logger is setup
|
44
|
-
@logger.debug "#{@debugname}.#{rofl_meth_trace}: #{text.to_s}"
|
43
|
+
@logger.debug "#{@debugname}.#{rofl_meth_trace.to_s}: #{text.to_s}"
|
45
44
|
end
|
46
45
|
#get method call trace
|
47
46
|
def rofl_meth_trace
|
47
|
+
last_meth_name = "notrace"
|
48
48
|
skip = 2 #indicates how many items we skip in the execution stack trace
|
49
49
|
call_trace = caller(skip)
|
50
|
-
|
51
|
-
|
52
|
-
last_meth_name = last_meth.delete("\`")
|
50
|
+
regexp = /\`.*?\'/
|
51
|
+
last_meth = call_trace[0][regexp]
|
52
|
+
last_meth_name = last_meth.delete("\`") unless last_meth.nil?
|
53
|
+
last_meth_name = last_meth_name.delete("\'") unless last_meth_name.nil?
|
53
54
|
return last_meth_name
|
54
55
|
end
|
55
56
|
#check if we or an object are ready to rofl
|
data/lib/rofl_trace.rb
CHANGED
@@ -13,6 +13,15 @@ module RoflTrace
|
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
+
#enable vm wide silent tracing
|
17
|
+
def rofl_enable_silent_trace event_regex = /^(call)/
|
18
|
+
#this is the Kernel::set_trace_func that we overwrite
|
19
|
+
trace_func = Proc.new do |event, file, line, id, binding, classname|
|
20
|
+
end
|
21
|
+
set_trace_func trace_func
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
16
25
|
#disable vm wide tracing
|
17
26
|
def rofl_disable_trace
|
18
27
|
set_trace_func nil
|
data/lib/test_rofl.rb
CHANGED