This commit is contained in:
John Lancaster
2024-10-21 03:15:59 +00:00
parent bc2224a919
commit de496509a9
3 changed files with 26 additions and 14 deletions

View File

@@ -43,6 +43,7 @@ class ADMain:
if hasattr(self, 'ad'):
self.ad.logger.info('Running asyncio event loop indefinitely...')
self.run_context.loop.run_forever()
self.ad.logger.debug('Gracefully stopped event loop')
else:
logging.error('Running ADMain without context manager')
@@ -59,7 +60,7 @@ if __name__ == '__main__':
{
'version': 1,
'disable_existing_loggers': False,
'formatters': {'basic': {'style': '{', 'format': '[yellow]{name}[/] {message}'}},
'formatters': {'basic': {'style': '{', 'format': '[yellow]{name:20}[/] {message}'}},
'handlers': {
'rich': {
'()': 'rich.logging.RichHandler',
@@ -69,9 +70,10 @@ if __name__ == '__main__':
'markup': True
}
},
'root': {'level': 'INFO', 'handlers': ['rich']},
'root': {'level': 'DEBUG', 'handlers': ['rich']},
}
)
with ADMain('/conf/ad-test/conf/appdaemon.yaml') as main:
main.run()
main.ad.logger.debug('Exiting main context from with statement')