Skip to content
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

Log messages to stdout instead of stderr #334

Merged
merged 15 commits into from
Oct 3, 2020
Merged

Conversation

elfjes
Copy link
Contributor

@elfjes elfjes commented Sep 9, 2020

fixes #328

@@ -20,7 20,7 @@


def init_logging(level=None, frmt=None, filename=None):
logging.basicConfig(level=level, format=frmt)
logging.basicConfig(level=level, format=frmt, stream=sys.stdout)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, could you make it also optional and possible to specify from the configuration? Thanks!

Copy link
Contributor

@mplanchard mplanchard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this patch! This was a good catch, and I like the direction. I have a few thoughts about ways we might be able to improve the logging experience a bit more. Let me know what you think!

@@ -94,10 101,6 @@ def usage():
-v
Enable verbose logging; repeat for more verbosity.

--log-conf <FILE>
read logging configuration from FILE.
By default, configuration is read from `log.conf` if found in server's dir.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! We must've forgotten to remove this at some point in the past

pypiserver/__main__.py Outdated Show resolved Hide resolved
@@ -117,6 120,9 @@ def usage():
A format-string selecting Http-Error properties to log; set to '%s' to see them all.
[Default: %(body)s: %(exception)s \n%(traceback)s]

--log-to-stdout
log messages to stdout instead of the default stderr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're touching this, it might be better to give people some more configurability with this, for example:

--log-to-stream
  Log messages to the specified stream. Valid values are "stdout", "stderr", or "none"

That way people can turn off string logging altogether if they want. With your refactor to the init_logging function, this should be pretty easy to add in. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I've added it to the PR. I've renamed it to log-stream to be more consistent with the log-file option

@elfjes
Copy link
Contributor Author

elfjes commented Sep 26, 2020

It took me a while to notice that the pipeline was failing, but it is fixed now.

Copy link
Contributor

@mplanchard mplanchard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Thanks very much for the contribution, and feel free to join us on zulip

@mplanchard mplanchard merged commit 8b19790 into pypiserver:master Oct 3, 2020
@elfjes elfjes deleted the iss328 branch October 8, 2020 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

access log printed to stderr
3 participants