Improved BootLog module
This commit is contained in:
		
							
								
								
									
										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