Redirecting the uvm_info outputs to a log file

Hi…
I have used the following code in test (which is a component) to redirect the outputs of `uvm_info to a specific text file.


int file;
file = $fopen("../test/xyz.txt");
set_report_default_file_hier (file);
set_report_severity_action (UVM_INFO, UVM_DISPLAY+UVM_LOG);

And I am able redirect the outputs of uvm_info’s from the test to that particular text file.

But, I am trying to redirect the outputs of uvm_info statements from adapter which is an object.
The methods like set_report_severity_action are not working in this class. And I know the reason for this.

So, I wanted to know if there is a way to redirect the outputs of uvm_infos from objects to a log file.

UVM classes that are not derived from uvm_report_object all use the global report handler in uvm_top. If you want a particulat object to have its own report settings, you can derive it from uvm_report_object instead of uvm_object. Or you can use `uvm_info_context and provide a handle to another reporting object. Many people use m_sequencer as the context for issuing sequence_item messages.

In reply to dave_59:

Hi Dave, Could you perhaps be a bit more specific? I’m trying to get a uvm_subscriber class to print all `uvm_info to a user-specified filename, and all I get is a file of 0 bytes. I have even tried this, just to at least try to get everything to print.

function void start_of_simulation_phase ( uvm_phase phase );
output_fd = $fopen( output_name, “w”);
uvm_top.set_report_default_file_hier ( output_fd );
$display(“RDY_VALID_PRINTER: set default output to ‘%s’”, output_name );
endfunction : start_of_simulation_phase