A-0.1 - Modularer Aufbau #13
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -7,10 +7,7 @@
|
|||||||
"activityBar.inactiveForeground": "#15202b99",
|
"activityBar.inactiveForeground": "#15202b99",
|
||||||
"activityBarBadge.background": "#06b9a5",
|
"activityBarBadge.background": "#06b9a5",
|
||||||
"activityBarBadge.foreground": "#15202b",
|
"activityBarBadge.foreground": "#15202b",
|
||||||
"editorGroup.border": "#fbed80",
|
|
||||||
"panel.border": "#fbed80",
|
|
||||||
"sash.hoverBorder": "#fbed80",
|
"sash.hoverBorder": "#fbed80",
|
||||||
"sideBar.border": "#fbed80",
|
|
||||||
"statusBar.background": "#f9e64f",
|
"statusBar.background": "#f9e64f",
|
||||||
"statusBar.foreground": "#15202b",
|
"statusBar.foreground": "#15202b",
|
||||||
"statusBarItem.hoverBackground": "#f7df1e",
|
"statusBarItem.hoverBackground": "#f7df1e",
|
||||||
|
@ -4,10 +4,12 @@ from cpl_core.application import ApplicationBuilder, ApplicationABC
|
|||||||
|
|
||||||
from gismo.application import Application
|
from gismo.application import Application
|
||||||
from gismo.startup import Startup
|
from gismo.startup import Startup
|
||||||
|
from modules.boot_log.boot_log_extension import BootLogExtension
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
app_builder = ApplicationBuilder(Application)
|
app_builder = ApplicationBuilder(Application)
|
||||||
|
app_builder.use_extension(BootLogExtension)
|
||||||
app_builder.use_startup(Startup)
|
app_builder.use_startup(Startup)
|
||||||
app: ApplicationABC = await app_builder.build_async()
|
app: ApplicationABC = await app_builder.build_async()
|
||||||
await app.run_async()
|
await app.run_async()
|
||||||
|
@ -7,7 +7,7 @@ from cpl_core.environment import ApplicationEnvironment
|
|||||||
|
|
||||||
from gismo_core.abc.bot_service_abc import BotServiceABC
|
from gismo_core.abc.bot_service_abc import BotServiceABC
|
||||||
from gismo_core.service.bot_service import BotService
|
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_abc import ModuleABC
|
||||||
from modules_core.abc.module_service_abc import ModuleServiceABC
|
from modules_core.abc.module_service_abc import ModuleServiceABC
|
||||||
from modules_core.service.module_service import ModuleService
|
from modules_core.service.module_service import ModuleService
|
||||||
|
22
src/modules/boot_log/boot_log.py
Normal file
22
src/modules/boot_log/boot_log.py
Normal file
@ -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')
|
19
src/modules/boot_log/boot_log_extension.py
Normal file
19
src/modules/boot_log/boot_log_extension.py
Normal file
@ -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())
|
@ -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')
|
|
Reference in New Issue
Block a user