New group logging
This commit is contained in:
1 parent
400837b41a
commit
cded4a0200
14 files changed
+324
-75
No files matched your search
+17
-3
@@ -183,10 +183,22 @@ class SmartObject(hass.Hass,LoggerInterface):
|
||||
# mute → entity → constants → templates_library → virtual_sensors
|
||||
# → attributes_override → dataset restore → on_initialize_smart_object()
|
||||
def initialize(self):
|
||||
self.initialize_logger_interface(self.get_ad_api())
|
||||
with self.log_group('initialization', self.name) as group:
|
||||
self.log(f"Initialization started [group=initialization:{group['id']}]")
|
||||
try:
|
||||
succeeded = self._initialize_smart_object()
|
||||
except BaseException:
|
||||
self.log(f"Initialization failed [group=initialization:{group['id']}]", level='ERROR')
|
||||
raise
|
||||
status = 'completed' if succeeded else 'failed'
|
||||
level = 'INFO' if succeeded else 'ERROR'
|
||||
self.log(f"Initialization {status} [group=initialization:{group['id']}]", level=level)
|
||||
|
||||
def _initialize_smart_object(self):
|
||||
try:
|
||||
#self.depends_on_module(["smartobject","virtualsensors","logger_interface"])
|
||||
|
||||
self.initialize_logger_interface(self.get_ad_api())
|
||||
self.log_info(f"Name = {self.name}")
|
||||
# mute: true → suppress all log output for this app
|
||||
try: self.mute_logger(self.args['mute'])
|
||||
@@ -272,8 +284,10 @@ class SmartObject(hass.Hass,LoggerInterface):
|
||||
self.log_info(self.get_dataset_name() + " loaded")
|
||||
except (FileNotFoundError,EOFError): pass #self.log_info("File " + self.get_dataset_name() + " not found (and it's ok)")
|
||||
self.on_initialize_smart_object()
|
||||
except ParsingException as e: self.log_error(str(e),stop_app = True)
|
||||
|
||||
except ParsingException as e:
|
||||
self.log_error(str(e), stop_app=True)
|
||||
return False
|
||||
return True
|
||||
|
||||
# AppDaemon shutdown hook. Persists self.dataset to disk (if set).
|
||||
def terminate(self):
|
||||
|
||||
Reference in new issue
Block a user