I thought it is for activating debug mode which prints all logging.debug() messages. But apparently that doesn't happen. The documentation simply says:
Turn on parser debugging output (for wizards only, depending on compilation options). See also PYTHONDEBUG.
Which doesn't explain anything in my eyes. Can somebody give a more verbose explanation and verify that there is really no default CPython Argument that activates debug logging?
From Parser/parser.c:
#ifdef Py_DEBUG
extern int Py_DebugFlag;
#define D(x) if (!Py_DebugFlag); else x
#else
#define D(x)
#endif
This D
macro is used with printf()
to print debugging messages when the debug flag is supplied and the interpreter is compiled with in debug mode. The debugging messages are intended for the developers of Python, people who work on Python itself (not to be confused with Python programmers, who are people who use Python). I've gone through the Python manual page and none of them activate the logging
debug mode. However, one can use the -i
flag in conjunction with the -c
to achieve the same affect:
python -i -c "import logging;logging.basicConfig(level=logging.DEBUG)"
The -d
option enables the python parser debugging flags. Unless you're hacking the Python interpreter and changing how it parses Python code, you're unlikely to ever need that option.
The logging infrastructure is a standard library module, not a builtin feature of the interpreter. It doesn't make much sense to have an interpreter flag that changes such a localized feature of a module.
Also, consider how logging level depends on the logging logger and handler you're using. You can set different levels for different loggers and handlers, for different parts of your application. For instance, when you want all DEBUG lines from anyone to appear in console, but INFO and above from a lib should be logged to a common file, and WARNING and ERROR to be logged to specific files for easier monitoring. You can set a global handler for DEBUG that logs to console, and other handlers that log the different levels to separate files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With