ZHA log helper (#25543)

* Logging helper.
* Use log helper for ZHA entities.
* Use log helper for ZHA core device.
* Log helper for ZHA core channels.
* Lint
* ZHA fixture fix.
This commit is contained in:
Alexei Chetroi 2019-07-30 15:19:24 -04:00 committed by GitHub
parent 2c144bc412
commit 5aa35b52cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 106 additions and 105 deletions

View file

@ -207,3 +207,27 @@ def async_is_bindable_target(source_zha_device, target_zha_device):
if any(bindable in bindables for bindable in matches):
return True
return False
class LogMixin:
"""Log helper."""
def log(self, level, msg, *args):
"""Log with level."""
raise NotImplementedError
def debug(self, msg, *args):
"""Debug level log."""
return self.log(logging.DEBUG, msg, *args)
def info(self, msg, *args):
"""Info level log."""
return self.log(logging.INFO, msg, *args)
def warning(self, msg, *args):
"""Warning method log."""
return self.log(logging.WARNING, msg, *args)
def error(self, msg, *args):
"""Error level log."""
return self.log(logging.ERROR, msg, *args)