#import "Basic"; #import "Print_Color"; #module_parameters (ENABLE_TRACING := true); qtrace :: ( $label: string = "", color: Console_Color = COLOR_DEFAULT, loc := #caller_location ) #expand { #if ENABLE_TRACING { ts_start := current_time_monotonic(); `defer delta_report(label, ts_start, #procedure_name(), color, loc); } } #scope_file COLOR_DEFAULT :: Console_Color.YELLOW; delta_report :: ( $label: string, ts_start: Apollo_Time, proc_name: string, color: Console_Color, loc: Source_Code_Location ) { ts_now := current_time_monotonic(); delta := ts_now - ts_start; us := to_microseconds(delta); ms := to_milliseconds(delta); s := to_seconds(delta); using loc; print_color("PROCEDURE: %", proc_name, color=color, style=.BOLD); print("\n"); #if label { print_color("Label: %", label, color=color); print("\n"); } print_color("Delta: % us % ms % s", us, ms, s, color=color); print("\n"); print_color( "Location: %: %:%", fully_pathed_filename, line_number, character_number, color=color ); print("\n\n"); }