-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-93557: add __main__ submodule to logging #93788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following commit authors need to sign the Contributor License Agreement: |
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this belongs in the stdlib - see my comments on the issue.
parser.add_argument("-r", "--reuse_logger", default=False, action="store_true", help="Reuse the same logger for multiple scripts.") | ||
parser.add_argument("-c", "--clear_logfile", default=False, action="store_true", help="Clear the log file before writing to it.") | ||
## the last argument is the file being executed | ||
parser.add_argument("script", default=None, nargs="?", help="Python script to be logged.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for the -m module
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I knew I forgot something, any ideas on a clean way to implement it?
parser.add_argument("-s", "--string_format", default="DEFAULT", help="Format for logs.") | ||
## these args aren't used on first run, but are used on subsequent runs | ||
parser.add_argument("-r", "--reuse_logger", default=False, action="store_true", help="Reuse the same logger for multiple scripts.") | ||
parser.add_argument("-c", "--clear_logfile", default=False, action="store_true", help="Clear the log file before writing to it.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure all these args/options are necessary/desired.
what about only allowing to use a config file ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do both a config file and the args/options. I'm just thinking of how it could be easy to use for anyone. Having a config file could be annoying for some people to add to their projects. But a config file could be added easily.
I had it in there for testing and forgot to remove it.
My earlier comment indicates that I'm not planning to merge this, and I have commented on the issue saying that I don't believe this belongs in the stdlib. To save you from spending more time on this issue, I'll close it now. |
gh-93557
usage:
python -m logging [-h] [-t] [-p|-d] [-f ] [-l <1-5>] [-r] [-c]
options:
-h, --help show this help message and exit
-t, --time_stamp Include time stamp in output.
-p, --remap_print Remap the "print" function to "logging.info".
-d, --double_print Remap "print" to a lambda printing and logging all print statements.
-f FILE, --file FILE Output log to file.
-l LEVEL, --level LEVEL
Log level [1-5] (1=debug, 2=info, 3=warning, 4=error, 5=critical)
-s STRING_FORMAT, --string_format STRING_FORMAT
Format for logs.
-r, --reuse_logger Reuse the same logger for multiple scripts.
-c, --clear_logfile Clear the log file before writing to it.