Hiding, Editing, or Adding debugging and info messages

How can I change the debug and info messages that appear in the terminal when I am running an automation through the terminal (e.g., python chemostat.py).

In particular, how can I hide/remove lines such as
xxxx DEBUG [app] [remove_waste] Cleaned up GPIO-12.
xxxx DEBUG [app] [add_media] Initialized GPIO-13 using hardware-timing, initial frequency = 200.0 hz.

How can I edit lines such as:
xxxx INFO [app] [add_media] 0.5mL
xxxx INFO [app] [dosing_automation] DilutionEvent: exchanged 1.0mL

And how can I add my own messages when running an automation? Is there a way to generate my own message every time self.execute() runs.

Thanks!

Example log:

2023-01-05T03:49:05+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:06+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:07+0000 INFO [app] [remove_waste] 1.0mL
2023-01-05T03:49:07+0000 DEBUG [app] [remove_waste] Initialized GPIO-12 using hardware-timing, initial frequency = 200.0 hz.
2023-01-05T03:49:19+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:19+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:25+0000 INFO [app] [add_media] 0.5mL
2023-01-05T03:49:25+0000 DEBUG [app] [add_media] Initialized GPIO-13 using hardware-timing, initial frequency = 200.0 hz.
2023-01-05T03:49:31+0000 DEBUG [app] [add_media] Cleaned up GPIO-13.
2023-01-05T03:49:31+0000 DEBUG [app] [add_media] Cleaned up GPIO-13.
2023-01-05T03:49:37+0000 INFO [app] [remove_waste] 0.5mL
2023-01-05T03:49:37+0000 DEBUG [app] [remove_waste] Initialized GPIO-12 using hardware-timing, initial frequency = 200.0 hz.
2023-01-05T03:49:43+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:43+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:44+0000 INFO [app] [remove_waste] 1.0mL
2023-01-05T03:49:44+0000 DEBUG [app] [remove_waste] Initialized GPIO-12 using hardware-timing, initial frequency = 200.0 hz.
^C2023-01-05T03:49:47+0000 DEBUG [app] [dosing_control] Exiting caused by signal Interrupt.
2023-01-05T03:49:56+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:56+0000 DEBUG [app] [remove_waste] Cleaned up GPIO-12.
2023-01-05T03:49:57+0000 INFO [app] [dosing_automation] DilutionEvent: exchanged 1.0mL

Hi @realPeteDavidson, you can do some of your asks:

To add your own messages, try something like:

    def execute(self) -> events.DilutionEvent:
        self.logger.debug(f"Here's a message, executing {self.alt_media_ml}ml alt media")
        self.check_for_update()
        ...
  

will print something like the following each time execute runs:

...
2023-01-06T20:48:01-0500 DEBUG  [dosing_automation] Here's a message, executing 0ml alt media
...

These use python “f-strings” - here’s a good intro to how they work.


The message DilutionEvent: exchanged 1.0mL is in your code:

        return events.DilutionEvent(
            f"exchanged {volume_actually_cycled[0]}mL",  # here it is, you can change this to whatever you want.
            data={"volume_actually_cycled": volume_actually_cycled[0]},
        )

New: you can also change the console_log_level field in the section [logging] in your config.ini. This will level will filter what level of messages are shown: debug is lowest, then info, warning, notice, error, and critical` is highest.

1 Like