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

Remove `eprintln!` usage from this library? #88

Open
ArniDagur opened this issue Apr 11, 2020 · 1 comment
Open

Remove `eprintln!` usage from this library? #88

ArniDagur opened this issue Apr 11, 2020 · 1 comment

Comments

@ArniDagur
Copy link
Contributor

@ArniDagur ArniDagur commented Apr 11, 2020

In the following Python code, I call Engine's add_filter_list method on the string contents of each downloaded block list.

            try:
                download.fileobj.seek(0)
                text = io.TextIOWrapper(download.fileobj, encoding="utf-8")
                self._engine.add_filter_list(text.read())
                text.close()
            except UnicodeDecodeError:
                message.info("Block list is not valid utf-8")
            finally:
                download.fileobj.close()

When I run said code on a few popular blocklists, the console is filled with Filter already exists:

...
Filter already exists
Filter already exists
Filter already exists
Filter already exists
Filter already exists
Filter already exists
17:14:30 INFO: Block lists have been successfully imported

Those particular messages come from src/engine.rs#L166 where the library prints to the console in case of an error. I'm personally not a fan of this kind of "logging", since there's no way for me as a consumer of the library to tell it not to print to the console.

@AndriusA Do you agree that another method of logging errors should be used? If so, what would be your preferred alternative approach? I'd be happy to make a PR.

@ArniDagur
Copy link
Contributor Author

@ArniDagur ArniDagur commented Apr 17, 2020

@AndriusA Hey! I have time over the weekend to work on this. Just tell me how you want it to be done, if at all.

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.