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

[Request] Add option to disable logger #59

Closed
Winning117 opened this issue Feb 3, 2020 · 6 comments · Fixed by #97
Closed

[Request] Add option to disable logger #59

Winning117 opened this issue Feb 3, 2020 · 6 comments · Fixed by #97

Comments

@Winning117
Copy link

By default this package will always print to a logger, but for my use case it only ends up cluttering the logs with "released, acquired, released, acquired, etc". I'd appreciate it if you could add the option to disable the logger :)

@liiight
Copy link

liiight commented Feb 9, 2020

You can probably do it yourself via the logging module:

import logging

logging.getLogger('py-filelock.filelock').setLevel(logging.ERROR) # not sure about the logger name but you get the point

@pquentin
Copy link

pquentin commented Apr 28, 2020

logging.getLogger("filelock").setLevel(logging.ERROR) works

@gaborbernat
Copy link
Member

We probably should add a section on this into the readme, if you make a PR for this we would be happy to review it, thanks!

@hkennyv
Copy link
Contributor

hkennyv commented Sep 30, 2021

@gaborbernat I believe that now, as of 3.2.0, it should now be:

logging.getLogger("filelock._api").setLevel(logging.DEBUG)

I think it makes more sense to keep the logger the same name as the package, which would require changing:

https://github.com/tox-dev/py-filelock/blob/c9b6d90b8d0d6f3971b97ce7bfd1b3402d58220e/src/filelock/_api.py#L7

to:

_LOGGER = logging.getLogger("filelock")

How does that sound?

@gaborbernat
Copy link
Member

Oh you're right 🙂

@gaborbernat
Copy link
Member

Please put in a PR we'll accept it 😊 (add a test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants