Print only the file name and exclude file path getting printed in the log file

Hello Everyone,

In the log file, The entire file path is printed instead of just the filename, This increases the log file size and also looks clumsy. Kindly let me know the option to pass, to disable the file path getting printed.

The log file has the below line,
UVM_INFO /design/users/vijay/icmanage_check/learn/uvm/tb/top.sv(28) @ 0: reporter [TOP] Calling RUN_TEST

Instead I would like the above line to look as below in the log file.
UVM_INFO top.sv(28) @ 0: reporter [TOP] Calling RUN_TEST

Thanks in advance
Vijay

In reply to maximus:

Simply extend the uvm_report_server class and override the compose message creating your own message with format. Anyway you could implement the a function which works on a given string starting from the end up to the first dot for instance or tue second one (the first one could ne the .sv extension). Then in your env you declare it and build it. In this way the nee report server class will be used shortening the message.

In reply to maximus:

Did you try
`uvm_info_context ?

In reply to chr_sue:

The uvm_*_context just allows you to change the emitter of the message not the file path. By setting the emitter (context) to be the uvm_top for instance you are going to avoid the hier printing. What you’be asked is: can i shorten the print ?

In reply to Rsignori92:

In reply to maximus:
Simply extend the uvm_report_server class and override the compose message creating your own message with format. Anyway you could implement the a function which works on a given string starting from the end up to the first dot for instance or tue second one (the first one could ne the .sv extension). Then in your env you declare it and build it. In this way the nee report server class will be used shortening the message.

Below is my uvm_report server, even though i specify as filename, the entire path is getting printed,

class my_report_server extends uvm_default_report_server;
    virtual function string compose_report_message( uvm_report_message  report_message,
                                                    string              report_object_name = "");

        uvm_severity    severity    =   report_message.get_severity();
        string          name        =   report_message.get_report_object().get_full_name();
        string          id          =   report_message.get_id();
        string          message     =   report_message.get_message();
        string          filename    =   report_message.get_filename();
        int             line        =   report_message.get_line();

        return $sformatf("%-8s |   %16s    |   %2d |   %0t |   %-21s   |   %-7s    |   %s ",
                        severity.name(), filename,line,$time,name,id,message);
    endfunction : compose_report_message 
endclass: my_report_server

The output still looks like below
UVM_ERROR | /design/users/vijey/icmanage_check/learn/uvm/tests/seq_arb_test.sv | 84 | 0 | uvm_test_top | ARB_TEST | Spawning the sequences

I want it to be like
UVM_ERROR | seq_arb_test.sv | 84 | 0 | uvm_test_top | ARB_TEST | Spawning the sequences

Any tips on how to control them?

In reply to maximus:

This is because get_filename returns the path including the file itself. You could try to override this method.

In reply to maximus:

The approach is: create a function which will start at the end of the file name and ruj through it up to the first “/” or "" and just you knowing replace the existing file name with the shortened one.

In reply to Rsignori92:

You might try this

In reply to chr_sue:

Thank you so much, the solution given by “kaushalmodi” in the above link worked like a charm.