Skip to content

Commit

Permalink
Allow the user to create their own logger name by overriding get_logg…
Browse files Browse the repository at this point in the history
…er_name()
  • Loading branch information
raysalemi committed Jul 1, 2024
1 parent 3581eb5 commit 261a598
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pyuvm/s06_reporting_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, name):
super().__init__(name)
uvm_root_logger = logging.getLogger('uvm')
# Every object gets its own logger
logger_name = self.get_full_name() + str(id(self))
logger_name = self.get_logger_name()
self.logger = uvm_root_logger.getChild(logger_name)
self.logger.setLevel(
level=uvm_report_object.get_default_logging_level())
Expand All @@ -68,6 +68,23 @@ def __init__(self, name):
self._uvm_formatter = PyuvmFormatter(self.get_full_name())
self.add_logging_handler(self._streaming_handler)

def get_logger_name(self):
"""
:returns: The name of the initial logger
Override this method if you want to change the way the logger name is
generated.
The default looks like this:
.. code-block:: python
return self.get_full_name() + str(id(self))
"""
return self.get_full_name() + str(id(self))

return self.get_full_name()

@staticmethod
def set_default_logging_level(default_logging_level):
"""
Expand Down

0 comments on commit 261a598

Please sign in to comment.