Logging or Printing information somewhere

I’m trying to test some code (a job), and this job has a method that is called via RepeatedTimer. How can I print out some information somewhere that I can see? For example, I see these messages sometimes:

2023-03-22T12:26:48-0700 DEBUG [background_job] Disconnected from MQTT with rc=7: The connection was lost.
2023-03-22T12:26:49-0700 INFO [background_job] Reconnected to the MQTT broker on leader.

How can I create these messages, and if the answer is through events, can you provide a short description of how I can use the events? I’m not worried about storing the data yet, I am more interested in using this to print out some information when certain functions run to check how the code is running.

job = MyJob()
main_loop = RepeatedTimer(60, job.main_loop).start()
job.block_until_disconnected()

On any BackgroundJob subclass, you can access the logger property:

x = 3.1415
job.logger.debug("what is {x}?")
# 2023-03-22T12:26:49-0700 DEBUG [background_job] what is 3.1415?

If you wanted to log without a background job, that’s possible too:

from pioreactor.logging import create_logger

logger = create_logger("my_script")
logger.debug(...)

Thanks! This is helpful.