Hi amic,
Sorry to bother you with what is more of a python question than a AppDaemon question but im trying to extend the logging so I can have individual files per app and was wondering if you could give some advice on it.
Here is what I have in def initialize
def initialize(self):
logger = logging.getLogger(self.name)
logger.setLevel(logging.DEBUG)
logfile = "/var/log/appdaemon/apps/AutoLights.{}.log".format(self.name)
filelogger = logging.FileHandler(logfile)
filelogger.setLevel(logging.DEBUG)
logger.addHandler(filelogger)
The im just using
logger.info('whatever)
currently im passing it in as follows, which is working ok.
logger=kwargs['logger`']
What do you think would be the best way of passing this to the other functions in the app. Making it global is no good as its shared by all the other AppDaemon apps?? Should I pass it around as an argument? is there a better (more established way of doing this?)
Cheers
Zak