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

Use "logging" instead of "print" to enable output-control #1328

Open
exhuma opened this issue Nov 15, 2022 · 0 comments
Open

Use "logging" instead of "print" to enable output-control #1328

exhuma opened this issue Nov 15, 2022 · 0 comments

Comments

@exhuma
Copy link

exhuma commented Nov 15, 2022

Currently proselint writes non-essential information onto stout. This is caused by using the print() function for those messages. For example, the following message

Using in-memory shelf for cache file /home/users/malbert/.cache/proselint/checks.airlinese.misc.check

is cause by

print('Using in-memory shelf for cache file %s' % cachepath)

This makes proselint excessively verbose on large projects and there is no way to circumvent this.

On typical CLI applications it is possible to redirect stderr somewhere else, for example I would expect to be able to do this:

proselint my_file.rst 2>/dev.null

to get only the important messages. Even better, I would expect to use something like a -q/--quiet flag instead.

By using the logging framework in Python the first point is automatic because log-messages are written by default to stderr.
The "quiet" flag is then also trivial to implement as one could just increase the log-level, for example:

if quiet:
    logging.getLogger().setLevel(logging.ERROR)

As it is now, I am forced to run proselint through a couple of negative grep calls to filter out everything I don't want to see. This is cumbersome, error prone and risks accidentally filtering out too much.

By having a "quiet" flag (or simply using logging and thus writing to stderr) would make this a lot easier and make the output much more readable.

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

No branches or pull requests

1 participant