# Log file for uvm object type class

**URL:** <https://verificationacademy.com/forums/t/log-file-for-uvm-object-type-class/39331>\
**Category:** UVM\
**Tags:** UVM, UVM-Reporting, uvm-info\
**Created:** [July 19, 2021, 12:52am UTC](https://verificationacademy.com/forums/t/log-file-for-uvm-object-type-class/39331 "2021-07-19T00:52:28Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![bhupeshpaliwal](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/b/ee59a6/32.png) [@bhupeshpaliwal](https://verificationacademy.com/forums/u/bhupeshpaliwal)\
**Post date:** [July 22, 2021, 4:05pm UTC](https://verificationacademy.com/forums/t/log-file-for-uvm-object-type-class/39331/8 "2021-07-22T16:05:56Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/log-file-for-uvm-object-type-class/39331/7):_  
Thanks to dave, I did managed to figure it out.  
To be honest, it’s not theoretical example … I have prepared a behavorial model and thus not intended to use any phasing aspect(which we get in uvm\_component) and hence started extending my class from uvm\_object. Intention was model to have separate log file.

As per dave suggestion, I tried to understand a bit and came up with following, though still has scope of improvement but works for time-being.

```verilog

class my_obj extends uvm_report_object;
  `uvm_object_utils(my_obj);
 
  function new(string name = "");
    super.new(name);
    tID = get_type_name();
    tID = tID.toupper();
  endfunction
 
  function void configure(uvm_component parent = null);
    string hier_s;
    uvm_verbosity verb;
    
    if(parent != null) begin
      hier_s = parent.get_full_name();
    end else begin
       uvm_coreservice_t cs = uvm_coreservice_t::get();
       parent = cs.get_root();
    end

    hier_s = (hier_s == "") ? hier_s : { hier_s, "." };

    hier_s = { hier_s, get_full_name(), ".log" }
    log = $fopen(hier_s, "w");
 
    if(!log) begin
      `uvm_fatal(tID, {hier_s, "can't open to write"});
    end
      
    verb = uvm_verbosity'(parent.get_report_verbosity_level());
    this.set_report_verbosity_level(verb);
    this.set_report_id_action(tID, UVM_LOG);
    this.set_report_id_file(tID, log);
    
 
  endfunction
 
  function void display();
    `uvm_info(tID, "this print goes to log file", UVM_HIGH);
  endfunction
 
  function void end_of_sim();
    if(log) $fclose(log);
  endfunction
 
  local int log = -1;
  protected string tID;
 
endclass
 

module try;
 
  my_obj obj;
 
  initial begin
    obj = my_obj::type_id::create("obj");
    obj.configure();
    obj.display();
    obj.end_of_sim(); 
  end
 
endmodule

```

---

_[View the full topic](https://verificationacademy.com/forums/t/log-file-for-uvm-object-type-class/39331)._
