Skip to content

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

Closed
wants to merge 6 commits into from
Closed

Conversation

MayD524
Copy link

@MayD524 MayD524 commented Jun 14, 2022

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.

@MayD524 MayD524 requested a review from vsajip as a code owner June 14, 2022 03:42
@ghost
Copy link

ghost commented Jun 14, 2022

The following commit authors need to sign the Contributor License Agreement:

Click the button to sign:
CLA not signed

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

Copy link
Member

@vsajip vsajip left a 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.

@AA-Turner AA-Turner added the pending The issue will be closed if no feedback is provided label Jun 14, 2022
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.")
Copy link
Contributor

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 ?

Copy link
Author

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.")
Copy link
Contributor

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 ?

Copy link
Author

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.

@merwok merwok changed the title [3.11] gh-93557: added __main__.py to logging module gh-93557: add __main__ submodule to logging Jun 14, 2022
@vsajip
Copy link
Member

vsajip commented Jun 15, 2022

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.

@vsajip vsajip closed this Jun 15, 2022
@AA-Turner AA-Turner removed the pending The issue will be closed if no feedback is provided label Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants