@@ -19,6 +19,8 @@ create or replace type body ut_debug_reporter is
1919 constructor function ut_debug_reporter(self in out nocopy ut_debug_reporter) return self as result is
2020 begin
2121 self.init($$plsql_unit);
22+ self.start_time := current_timestamp();
23+ self.event_time := current_timestamp();
2224 return;
2325 end;
2426
@@ -28,26 +30,41 @@ create or replace type body ut_debug_reporter is
2830 end;
2931
3032 overriding member procedure on_event( self in out nocopy ut_debug_reporter, a_event_name varchar2, a_event_item ut_event_item) is
31- begin
33+ c_time constant timestamp := current_timestamp();
34+ c_time_from_start constant interval day(0) to second(6) := (c_time - self.start_time);
35+ c_time_from_prev constant interval day(0) to second(6) := (c_time - self.event_time);
36+ l_debug varchar2(32767);
37+ l_stack varchar2(32767) := dbms_utility.format_call_stack();
38+ begin
39+ l_stack := regexp_replace(
40+ substr( l_stack, instr( l_stack, chr(10), 1, 6 ) +1 ),
41+ '[0-9abcdefx]+ +([0-9]+) +(package |type )?(body )?(.*)','at "\4", line \1');
42+
3243 if a_event_name = ut_event_manager.gc_initialize then
3344 self.on_initialize(null);
45+ self.print_text('<DEBUG_LOG>');
3446 end if;
47+ l_debug :=
48+ to_clob( '<DEBUG>' || chr(10)
49+ || ' <TIMESTAMP>' || ut_utils.to_string(c_time) || '</TIMESTAMP>' || chr(10)
50+ || ' <TIME_FROM_START>' || c_time_from_start || '</TIME_FROM_START>' || chr(10)
51+ || ' <TIME_FROM_PREVIOUS>' || c_time_from_prev || '</TIME_FROM_PREVIOUS>' || chr(10)
52+ || ' <EVENT_NAME>' || a_event_name || '</EVENT_NAME>' || chr(10)
53+ || ' <CALL_STACK>' || l_stack || '</CALL_STACK>' || chr(10)
54+ );
3555 if a_event_item is not null then
3656 self.print_clob(
37- to_clob( '<DEBUG><EVENT_NAME>' || a_event_name || '</EVENT_NAME>' || chr(10) )
38- || a_event_item.to_clob()
39- || to_clob('</DEBUG>'),
57+ to_clob( l_debug ) || a_event_item.to_clob() || to_clob('</DEBUG>'),
4058 ut_event_manager.gc_debug
4159 );
4260 else
43- self.print_clob(
44- '<DEBUG><EVENT_NAME>' || a_event_name || '</EVENT_NAME>' || chr(10) || '</DEBUG>',
45- ut_event_manager.gc_debug
46- );
61+ self.print_clob( l_debug || '</DEBUG>', ut_event_manager.gc_debug );
4762 end if;
4863 if a_event_name = ut_event_manager.gc_finalize then
64+ self.print_text('</DEBUG_LOG>');
4965 self.on_finalize(null);
5066 end if;
67+ self.event_time := current_timestamp();
5168 end;
5269
5370end;
0 commit comments