-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Choose logging handler via --log-handler
CLI option
#3293
Conversation
* pelican/__init__.py (parse_arguments): Declare new --logs-handler argument. Uses a string instead of a `type=` argument to get better error messages when passed an incorrect choice. (main): Pass `args.logs_handler` to `init_logging` * pelican/log.py: Expose default log handler as `DEFAULT_LOG_HANDLER`. (init): Pass handler to `logging.basicConfig`. Closes getpelicanGH-3292.
--logs-handler
CLI option
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.
Hi @cpitclaudel. Thank you for the quick corrections. Apologies for the delay in moving this forward. Upon another look, I think I would prefer to standardize on "log" instead of the plural "logs". We already have DEFAULT_LOG_HANDLER
, for example, and therefore I think it would be more consistent to use LOG_HANDLERS
, --log-handler
, et cetera, instead of the plural versions. Unless there are any objections, would you be so kind as to make those changes so we can merge your contribution?
No worries! No objection from me (pushed), but note that this is inconsistent with |
--logs-handler
CLI option--log-handler
CLI option
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 saw that but decided that particularly discrepancy is okay for now. We shall strive for eventual consistency! 😉
@avaris: Any thoughts on this PR?
I'm curious what use this flag would be put to. It would be constructive, I think, to include documentation for how to use it, how to define a new handler, and an example custom handler. |
I use it in makefiles, because the forced line wrapping that the rich handler does breaks hyperlinks:
With this format my terminal and my IDE don't let me click on the file in question to navigate to it.
Defining a custom handler is something the Pelican devs would do, not users. These are standard Python log handlers, so the appropriate documentation would be https://docs.python.org/3/library/logging.handlers.html |
I was just about to request this. Are there any outstanding issues or is this fully approved? |
Unless there are further comments from others, I intend to merge the Ruff-related PR (3239) and then this one. |
Many thanks for your enhancement, Clément! 🌟 |
WOW! Now if we can re-add the $ python -m pelican --log-handler=plain -s /tmp/pelicanconf-invalid-PATH-1
load_source: AttributeError: 'NoneType' object has no attribute 'loader' See the word Instead of the currently HEAD commit shows the following: $ python -m pelican --log-handler=plain -s /tmp/pelicanconf-invalid-PATH-1
AttributeError: 'NoneType' object has no attribute 'loader' Currently, we have no idea which method/procedures (that Furthermore, I've investigated a quick fix for the above and was unable to leverage the above but applied patch which rendered the inability to use such |
@egberts I'm sorry, I don't really understand what you're saying |
pelican/__init__.py
(parse_arguments): Declare new--log-handler argument
.Uses a string instead of a
type=
argument to get better error messages when passed an incorrect choice.(main): Pass
args.logs_handler
toinit_logging
DEFAULT_LOG_HANDLER
.(init): Pass handler to
logging.basicConfig
.Pull Request Checklist
Resolves: GH-3292
Question: I think there's no tests for the logger?
Question: I think there's no separate documentation for the CLI, I just added an argparse
help