Hi! I’m trying to change the logging level of a SerialLogHandler after its initial setup to enable/disable serial debugging. As far as I can tell, log handlers do not have set functions and simply replacing the log handler using
Thank you both very much for your help and insights! The solution @rickkas7 proposes is along the lines of what I need, with the difference that I want to be able to switch both ways. To facilitate cases where a decrease in logging granularity is desired, the previously added handler needs to be removed. I have implemented a solution that works both ways, but I feel there might be a more elegant solution.
I’d love to hear any thoughts on how to improve this function; I should be all set to implement the rest now.
@armor: The reason I would like to switch logging levels on runtime is the follow: I use the serial connection for general debugging as well as occasional calibration. While calibrating, I want to send a serial command to temporarily reduce serial logging as it limits the communication speed. Once the calibration routine is done, I send the serial command to switch back to more detailed logging.
I suspect I may not be the only one with this idea, so including an example in the documentation and/or including a StreamLogHanlder.setLevel() function may be worthwhile.