How does one log a warning without creating a logger python? I also want to make sure it DOES log properly.
Is:
import logging
logging.warning('warning')
enough?
CodePudding user response:
Yes:
import logging
logging.warning('warning')
ouput:
WARNING:root:warning
CodePudding user response:
If I understand you want logging without all the hassle with setting up a logger. If you don't mind installing third-party package, have a look at loguru. It is ready to use out of the box without boilerplate:
from loguru import logger
logger.warning("That's it, beautiful and simple logging!")
Check the docs for more info.