Hi,
I want to create a framework for our experiments, hence I created a few classes to separate concerns.
However, I have problems using the logging module in python. When using pure python (i.e. python mycode.py), my log messages are printed to the console as expected, when using artiq_run or artiq_run.run() the console stays empty.
How do I make artiq print my host code messages? The experiment itself runs normally.
from artiq.language.environment import EnvExperiment
from artiq.experiment import *
from artiq.frontend import artiq_run
from artiq.language.core import (delay, kernel, )
from artiq.language.units import ms, ns, dB, MHz
from helpers.BaseRack import BaseRack
from helpers.GlobalLogger import GlobalLogger
class urukul_minimum_delay(EnvExperiment, GlobalLogger):
def build(self):
self._base_rack = BaseRack(self)
@kernel
def run(self):
(omitted)
class foo(GlobalLogger):
def __init__(self):
self._base_rack = BaseRack(self)
if __name__ == "__main__":
# prints log messages from BaseRack class
foo = foo()
# does not print messages from BaseRack class
artiq_run.run()
from artiq.experiment import *
from helpers.GlobalLogger import GlobalLogger
class BaseRack(GlobalLogger):
_devices = [
"core",
"urukul0_cpld",
"urukul0_ch0",
"urukul0_ch1",
"urukul0_ch2",
"urukul0_ch3",
]
def __init__(self, experiment):
super().__init__()
self.logger.info("Creating devices...")
for device in BaseRack._devices:
experiment.setattr_device(device)
self.logger.debug(device)
import logging
class GlobalLogger():
def __init__(self):
self.logger = logging.getLogger(self.__class__.__name__)