Improved logging
This commit is contained in:
		| @@ -16,13 +16,15 @@ class BootLog(ModuleABC): | ||||
|         self._logger = logger | ||||
|         self._bot = bot | ||||
|         ModuleABC.__init__(self) | ||||
|         self._logger.trace(__name__, f'Module {type(self)} loaded') | ||||
|  | ||||
|     async def on_ready(self): | ||||
|         self._logger.info(__name__, f'Bot started') | ||||
|         self._logger.debug(__name__, f'Module {type(self)} started') | ||||
|         try: | ||||
|             start_time = self._config.get_configuration('StartTime') | ||||
|             start_time = self._config.get_configuration('Bot_StartTime') | ||||
|             init_time = round((datetime.now() - start_time).total_seconds(), 2) | ||||
|             self._logger.info(__name__, f'Init time:  {init_time}s') | ||||
|             self._config.add_configuration('InitTime', init_time) | ||||
|             self._logger.debug(__name__, f'Bot Init time:  {init_time}s') | ||||
|             # print warning if initialisation took too long | ||||
|             if init_time >= 30: | ||||
|                 self._logger.warn(__name__, 'It takes long time to start the bot!') | ||||
| @@ -36,4 +38,6 @@ class BootLog(ModuleABC): | ||||
|          | ||||
|         self._logger.header(f'{self._bot.user.name}:') | ||||
|         if self._logging_st.console.value >= LoggingLevelEnum.INFO.value: | ||||
|             Console.banner(self._bot.user.name) | ||||
|             Console.banner(self._bot.user.name) | ||||
|          | ||||
|         self._logger.trace(__name__, f'Module {type(self)} stopped') | ||||
| @@ -13,5 +13,5 @@ class BootLogExtension(ApplicationExtensionABC): | ||||
|  | ||||
|     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()) | ||||
|         logger.debug(__name__, 'BootLog extension started') | ||||
|         config.add_configuration('Bot_StartTime', datetime.now()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user