507 f"#WARNING\n\ndyno kill worker `{prog}%` completed !"
508 f"\n`{rem}`s remaining !")
509 warned = True
510 LOG.info(f"< dyno kill worker ... ({prog}%)({mins}) >")511 await asyncio.sleep(1)
512 count += 1
513 LOG.info("< state changed to online ! >")
492 try:
493 system.shutdown()
494 except Exception as h_e: # pylint: disable=broad-except
495 LOG.error(f"heroku app error : {h_e}")496 offline_start_time += 20
497 await asyncio.sleep(10)
498 continue
187 done.append(tmp)
188
189 if done:
190 _LOG.info(f"{work_type.rstrip('e')}ed {plg}")191
192 return done
263
264 tasks.clear()
265
266 _LOG.info(f"on_{meth} tasks completed !")267
268 async def start(self) -> None:
269 self._event.clear()
259 try:
260 await task
261 except Exception as i_e:
262 _LOG.error(f"({meth}) [{plg.cat}/{plg.name}] - {i_e}")263
264 tasks.clear()
265
Formatting the message manually before passing it to a logging
call does unnecessary work if logging is disabled. Consider using the logging
module's built-in formatting features to avoid that.
If your logging level is set to "WARNING"
, but the logging call is:
logging.debug("Data: %s", data)
In the above example, there will be no logging as the level debug
is below warning
. The conversion of the data
object to a string will be skipped by the logging module resulting in improved performance.
logging.debug(f"Data: {data}")
In the code shown above, the conversion of the data
object to a string will happen regardless of whether the message is logged or not (which is based on the log level).
import logging
import inspect
logging.basicConfig(level=logging.INFO)
logging.debug(f"Entered function {inspect.stack[0][3]}"))
import logging
import inspect
logging.basicConfig(level=logging.INFO)
logging.debug("Entered function %s", inspect.stack[0][3])