Log file for uvm object type class

In reply to bhupeshpaliwal:
I have tried to visualize your problem. Please find the code below:

import uvm_pkg::*;
`include "uvm_macros.svh"

class my_obj extends uvm_object;
  `uvm_object_utils(my_obj);

  local int log = -1;
  string tID;
 
 
  function new(string name = "");
    super.new(name);
  endfunction
 
  function void build_phase(uvm_phase phase);
    tID = get_type_name();
    tID = tID.toupper();
    `uvm_info(get_type_name(), $sformatf("my_comp build_phase"), UVM_MEDIUM)
    `uvm_info(get_type_name(), $sformatf("tID = %s", tID), UVM_MEDIUM)
  endfunction

  function void configure(uvm_component creator = null);
    if(creator != null) begin
      string hier_s;
      string creator_s;  
 
      creator_s = creator.get_full_name();
      `uvm_info(get_type_name(), $sformatf("creator = %s", creator_s), UVM_MEDIUM)
      hier_s = { creator_s, ".", get_full_name(), ".log" };
      `uvm_info(get_type_name(), $sformatf("filename = %s", hier_s), UVM_MEDIUM)
      log = $fopen(hier_s, "w");
 
      if(!log) begin
        `uvm_fatal(tID, {hier_s, "can't open to write"});
      end
 
     `uvm_info(get_type_name(), $sformatf("my_obj tID = %s", tID), UVM_MEDIUM)
      creator.set_report_id_file(tID, log);
      creator.set_report_id_action(tID, UVM_LOG);
    end
 
  endfunction
 
  function void disp(string arg);
    `uvm_info(arg, "this print goes to log file", UVM_HIGH)
  endfunction
 
  function void end_of_sim();
    if(log) $fclose(log);
  endfunction
 
endclass
 
class my_comp extends uvm_component;
  `uvm_component_utils(my_comp);

  my_obj obj;
  string ID;
 
  function new(string name = "", uvm_component parent = null);
    super.new(name, parent);
  endfunction
 
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    obj = my_obj::type_id::create("obj");
    `uvm_info(get_type_name(), $sformatf("my_comp build_phase"), UVM_MEDIUM)
    obj.configure(this);
    ID = obj.tID;
    `uvm_info(get_type_name(), $sformatf("my_compID = %s", ID), UVM_MEDIUM)
  endfunction

  function void report_phase(uvm_phase phase);
    obj.end_of_sim();
  endfunction
 
  function void disp(string arg);
    obj.disp(arg);
  endfunction
 
endclass
 
module try;
import uvm_pkg::*;
`include "uvm_macros.svh"
 
  my_comp comp;
  initial begin
    run_test("my_comp");
    comp.disp(comp.ID);
    `uvm_info("top", $sformatf("comp = %p", comp), UVM_MEDIUM)
    `uvm_info("top", $sformatf("comp ID = %s", comp.ID), UVM_MEDIUM)
   end 
endmodule


You have to different types of dynaic obejcts (classes) in your example, i.e. uvm_component and uvm_object.
uvm_component classes are used to build yout tesbench. These objects are constructed at runtime 0.
The 2nd class type is uvm_object. This type is used to create sequence_items and sequences. They do not belong to the hierarchy of your testbench And you cannot simply share data between the different types. You are trying this and you are failing. Please see the simulation log-file.