diff --git a/.vscode/settings.json b/.vscode/settings.json index 3062c47..10cee69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,10 +7,7 @@ "activityBar.inactiveForeground": "#15202b99", "activityBarBadge.background": "#06b9a5", "activityBarBadge.foreground": "#15202b", - "editorGroup.border": "#fbed80", - "panel.border": "#fbed80", "sash.hoverBorder": "#fbed80", - "sideBar.border": "#fbed80", "statusBar.background": "#f9e64f", "statusBar.foreground": "#15202b", "statusBarItem.hoverBackground": "#f7df1e", diff --git a/src/gismo/main.py b/src/gismo/main.py index ad64e2d..98aa58b 100644 --- a/src/gismo/main.py +++ b/src/gismo/main.py @@ -4,10 +4,12 @@ from cpl_core.application import ApplicationBuilder, ApplicationABC from gismo.application import Application from gismo.startup import Startup +from modules.boot_log.boot_log_extension import BootLogExtension async def main(): app_builder = ApplicationBuilder(Application) + app_builder.use_extension(BootLogExtension) app_builder.use_startup(Startup) app: ApplicationABC = await app_builder.build_async() await app.run_async() diff --git a/src/gismo/startup.py b/src/gismo/startup.py index 020f76f..bfe0155 100644 --- a/src/gismo/startup.py +++ b/src/gismo/startup.py @@ -7,7 +7,7 @@ from cpl_core.environment import ApplicationEnvironment from gismo_core.abc.bot_service_abc import BotServiceABC from gismo_core.service.bot_service import BotService -from modules.boot_log.main import BootLog +from modules.boot_log.boot_log import BootLog from modules_core.abc.module_abc import ModuleABC from modules_core.abc.module_service_abc import ModuleServiceABC from modules_core.service.module_service import ModuleService diff --git a/src/modules/boot_log/boot_log.py b/src/modules/boot_log/boot_log.py new file mode 100644 index 0000000..83a03a0 --- /dev/null +++ b/src/modules/boot_log/boot_log.py @@ -0,0 +1,22 @@ +from datetime import datetime + +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.logging import LoggerABC + +from gismo_core.abc.bot_service_abc import BotServiceABC +from modules_core.abc.module_abc import ModuleABC +from modules_core.abc.module_service_abc import ModuleServiceABC + + +class BootLog(ModuleABC): + + def __init__(self, config: ConfigurationABC, logger: LoggerABC): + self._config = config + self._logger = logger + ModuleABC.__init__(self) + + async def on_ready(self): + self._logger.info(__name__, f'Bot started') + start_time = self._config.get_configuration('StartTime') + init_time = round((datetime.now() - start_time).total_seconds(), 2) + self._logger.debug(__name__, f'InitTime: {init_time}s') diff --git a/src/modules/boot_log/boot_log_extension.py b/src/modules/boot_log/boot_log_extension.py new file mode 100644 index 0000000..8bd8e36 --- /dev/null +++ b/src/modules/boot_log/boot_log_extension.py @@ -0,0 +1,19 @@ +from datetime import datetime + +from cpl_core.application.application_extension_abc import \ + ApplicationExtensionABC +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.dependency_injection.service_provider_abc import \ + ServiceProviderABC +from cpl_core.logging import LoggerABC + + +class BootLogExtension(ApplicationExtensionABC): + + def __init__(self): + pass + + async def run(self, config: ConfigurationABC, services: ServiceProviderABC): + logger: LoggerABC = services.get_service(LoggerABC) + logger.trace(__name__, 'Boot extension started') + config.add_configuration('StartTime', datetime.now()) diff --git a/src/modules/boot_log/main.py b/src/modules/boot_log/main.py deleted file mode 100644 index 23ba19f..0000000 --- a/src/modules/boot_log/main.py +++ /dev/null @@ -1,15 +0,0 @@ -from cpl_core.logging import LoggerABC - -from gismo_core.abc.bot_service_abc import BotServiceABC -from modules_core.abc.module_abc import ModuleABC -from modules_core.abc.module_service_abc import ModuleServiceABC - - -class BootLog(ModuleABC): - - def __init__(self, logger: LoggerABC): - self._logger = logger - ModuleABC.__init__(self) - - async def on_ready(self): - self._logger.info(__name__, f'Bot started')