Python has some beautiful logging. Here is my goto format:
import logging
logging.basicConfig(
format="%(levelname)-7s | %(asctime)s | %(filename)12s:%(funcName)-12s | %(message)s",
datefmt="%I:%M:%S %p %d/%m/%Y",
level=logging.INFO,
)
Sent here from a help forum? Link to heading
If you’ve been sent the link to this page from some form of help forum with me asking for logs, use this please.
import logging
logging.basicConfig(
format="%(levelname)-7s | %(asctime)s | %(filename)12s:%(funcName)-12s | %(message)s",
datefmt="%I:%M:%S %p %d/%m/%Y",
level=logging.DEBUG,
)
Shushing loggers Link to heading
It’s nice to disable loggers sometimes
import logging
logger = logging.getLogger("module.submodule")
logger.setLevel(logging.WARNING)
Discord bot logging Link to heading
This is my go-to logging setup
import logging
logging.basicConfig(
format="%(levelname)-7s | %(asctime)s | %(filename)12s:%(funcName)-12s | %(message)s",
datefmt="%I:%M:%S %p %d/%m/%Y",
level=logging.INFO,
)
gateway_logger = logging.getLogger("disnake.gateway")
gateway_logger.setLevel(logging.WARNING)
client_logger = logging.getLogger("disnake.client")
client_logger.setLevel(logging.WARNING)
http_logger = logging.getLogger("disnake.http")
http_logger.setLevel(logging.WARNING)