I have frequent doubts when I write python modules and classes, specifically:
Where/how should I put the main flag that controls logging and where/how to create the logger,
Should it be at the module level? ---thus need to have some
global MyLoggeralmost everywhere inside each method.Should it be an argument passed to methods and/or classes? Perhaps to decide if a method or class needed it or not, maybe I could use the
**argsstars magic, with call likemyMethod(..., logger=Mylogger)?Where should I define/set the
I_logged_somethingflag? (...or should I rely on theif MyLogger: MyLogger.log('something'))What about when the class or module is imported?
What is the Pythonic way of logging? How do you use the logging tools?