From 245192192313e7aab9789576fa7b1efdde63d3cb Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Thu, 10 Dec 2020 02:20:14 -0800 Subject: [PATCH] Replace SimLog with logger --- cocotbext/axi/axi_master.py | 6 +++--- cocotbext/axi/axi_ram.py | 7 ++++--- cocotbext/axi/axil_master.py | 6 +++--- cocotbext/axi/axil_ram.py | 7 ++++--- cocotbext/axi/axis.py | 8 ++++---- cocotbext/axi/stream.py | 8 ++++---- 6 files changed, 22 insertions(+), 20 deletions(-) diff --git a/cocotbext/axi/axi_master.py b/cocotbext/axi/axi_master.py index a2c1579..1fabd9c 100644 --- a/cocotbext/axi/axi_master.py +++ b/cocotbext/axi/axi_master.py @@ -22,11 +22,11 @@ THE SOFTWARE. """ +import logging from collections import deque, namedtuple, Counter import cocotb from cocotb.triggers import Event -from cocotb.log import SimLog from .version import __version__ from .constants import AxiBurstType, AxiLockType, AxiProt, AxiResp @@ -49,7 +49,7 @@ AxiReadResp = namedtuple("AxiReadResp", ["address", "data", "resp", "user"]) class AxiMasterWrite(object): def __init__(self, entity, name, clock, reset=None, max_burst_len=256): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI master (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -365,7 +365,7 @@ class AxiMasterWrite(object): class AxiMasterRead(object): def __init__(self, entity, name, clock, reset=None, max_burst_len=256): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI master (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axi_ram.py b/cocotbext/axi/axi_ram.py index 9c58647..85bff11 100644 --- a/cocotbext/axi/axi_ram.py +++ b/cocotbext/axi/axi_ram.py @@ -22,8 +22,9 @@ THE SOFTWARE. """ +import logging + import cocotb -from cocotb.log import SimLog from .version import __version__ from .constants import AxiBurstType, AxiProt, AxiResp @@ -33,7 +34,7 @@ from .memory import Memory class AxiRamWrite(Memory): def __init__(self, entity, name, clock, reset=None, size=1024, mem=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI RAM model (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -145,7 +146,7 @@ class AxiRamWrite(Memory): class AxiRamRead(Memory): def __init__(self, entity, name, clock, reset=None, size=1024, mem=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI RAM model (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axil_master.py b/cocotbext/axi/axil_master.py index 949d641..2b43e8e 100644 --- a/cocotbext/axi/axil_master.py +++ b/cocotbext/axi/axil_master.py @@ -22,11 +22,11 @@ THE SOFTWARE. """ +import logging from collections import deque, namedtuple import cocotb from cocotb.triggers import Event -from cocotb.log import SimLog from .version import __version__ from .constants import AxiProt, AxiResp @@ -45,7 +45,7 @@ AxiLiteReadResp = namedtuple("AxiLiteReadResp", ["address", "data", "resp"]) class AxiLiteMasterWrite(object): def __init__(self, entity, name, clock, reset=None): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI lite master (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -231,7 +231,7 @@ class AxiLiteMasterWrite(object): class AxiLiteMasterRead(object): def __init__(self, entity, name, clock, reset=None): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI lite master (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axil_ram.py b/cocotbext/axi/axil_ram.py index 5ffbd0c..7e2925f 100644 --- a/cocotbext/axi/axil_ram.py +++ b/cocotbext/axi/axil_ram.py @@ -22,8 +22,9 @@ THE SOFTWARE. """ +import logging + import cocotb -from cocotb.log import SimLog from .version import __version__ from .constants import AxiProt, AxiResp @@ -33,7 +34,7 @@ from .memory import Memory class AxiLiteRamWrite(Memory): def __init__(self, entity, name, clock, reset=None, size=1024, mem=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI lite RAM model (write)") self.log.info("cocotbext-axi version %s", __version__) @@ -103,7 +104,7 @@ class AxiLiteRamWrite(Memory): class AxiLiteRamRead(Memory): def __init__(self, entity, name, clock, reset=None, size=1024, mem=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.log.info("AXI lite RAM model (read)") self.log.info("cocotbext-axi version %s", __version__) diff --git a/cocotbext/axi/axis.py b/cocotbext/axi/axis.py index e51e7f2..b37d072 100644 --- a/cocotbext/axi/axis.py +++ b/cocotbext/axi/axis.py @@ -22,12 +22,12 @@ THE SOFTWARE. """ +import logging from collections import deque import cocotb from cocotb.triggers import RisingEdge, ReadOnly, Timer, First, Event from cocotb.bus import Bus -from cocotb.log import SimLog from .version import __version__ @@ -215,7 +215,7 @@ class AxiStreamSource(object): _optional_signals = ["tvalid", "tready", "tlast", "tkeep", "tid", "tdest", "tuser"] def __init__(self, entity, name, clock, reset=None, byte_size=None, byte_lanes=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.entity = entity self.clock = clock self.reset = reset @@ -429,7 +429,7 @@ class AxiStreamSink(object): _optional_signals = ["tvalid", "tready", "tlast", "tkeep", "tid", "tdest", "tuser"] def __init__(self, entity, name, clock, reset=None, byte_size=None, byte_lanes=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.entity = entity self.clock = clock self.reset = reset @@ -632,7 +632,7 @@ class AxiStreamMonitor(object): _optional_signals = ["tvalid", "tready", "tlast", "tkeep", "tid", "tdest", "tuser"] def __init__(self, entity, name, clock, reset=None, byte_size=None, byte_lanes=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.entity = entity self.clock = clock self.reset = reset diff --git a/cocotbext/axi/stream.py b/cocotbext/axi/stream.py index 9eabca5..a1f8bfc 100644 --- a/cocotbext/axi/stream.py +++ b/cocotbext/axi/stream.py @@ -22,12 +22,12 @@ THE SOFTWARE. """ +import logging +from collections import deque + import cocotb from cocotb.triggers import RisingEdge, ReadOnly, Event, First, Timer from cocotb.bus import Bus -from cocotb.log import SimLog - -from collections import deque class StreamTransaction(object): @@ -65,7 +65,7 @@ class StreamBase(object): _transaction_obj = StreamTransaction def __init__(self, entity, name, clock, reset=None, *args, **kwargs): - self.log = SimLog("cocotb.%s.%s" % (entity._name, name)) + self.log = logging.getLogger(f"cocotb.{entity._name}.{name}") self.entity = entity self.clock = clock self.reset = reset