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

refactor print statements with the logging module #160

Closed
MattHJensen opened this issue Mar 5, 2015 · 6 comments
Closed

refactor print statements with the logging module #160

MattHJensen opened this issue Mar 5, 2015 · 6 comments

Comments

@MattHJensen
Copy link
Contributor

Here are the relevant lines:

https://github.com/OpenSourcePolicyCenter/Tax-Calculator/blob/master/taxcalc/calculate.py#L93-L99

@martinholmer
Copy link
Collaborator

@MattHJensen, issue #160 from March 2015 seems to be out-of-date. As far as I can see, there are no print statements in the calculate.py file other than the optional:

You loaded data for ...
Your data have been extrapolated to ...

And, again as far as I can see, there is no "logging module" anywhere in Tax-Calculator.
Can we close issue #160? Or does something useful need to be done with the current code?

@MattHJensen
Copy link
Contributor Author

@martinholmer, this issue is referencing the optional print statements you have highlighted:

You loaded data for ...
Your data have been extrapolated to ...

When I committed those print statements in #147, @talumbau suggested refactoring them with Python's built in logging module.

I remember that T.J. explained the benefits to me on the phone, but I don't remember them now. @talumbau, could you remind us of the advantages of using the logging module versus print statements in this context?

@talumbau
Copy link
Member

Sure. The built-in Python logging module is quite powerful. The documentation is quite extensive and, in my view, the module might suffer a bit from overdesign. But there are two basic ideas that are really great:

  • log levels: sometimes I want very verbose logs, perhaps if I am debugging a potential problem. Sometimes I only want to see events in my log if there is a critical problem. As the writer of the code, you can choose the appropriate log level for your message. As the runner of the code, you can choose (at runtime) how verbose you want the logging to be during your particular execution.
  • log output destination: sometimes I might want all log messages to go to a file, sometimes I might want log messages to go to standard out or standard error. This is configurable by the caller of the code.

And the final nice feature is that if you don't want to care about any of that, you can always replace print("Some important info here") with logging.info("Some important info here") and the default settings of the logging module will pretty much make it so that you get the same result (that message will print to standard out). It's just that you'll have the option to customize your messages a lot more now.

@mramanathan
Copy link

@talumbau, could you please confirm if this code 'refactoring' is still on the project's radar (of course, issue isn't closed). I can help with logging module. Shall I go ahead ?

/Ram

@martinholmer
Copy link
Collaborator

@talumbau and @mramanathan, I honestly don't see a positive net benefit (that is, benefits minus development/maintenance costs) to using the logging module. If it could work inside the functions in the functions.py file, I would reconsider my assessment. But I assume the numba magic in those functions rules out the use of the Python logging module, right?

I think there are many other much higher priority things to do than what is described in issue #160.
I think issue #160 should be closed.

@MattHJensen @Amy-Xu @GoFroggyRun @andersonfrailey

@martinholmer
Copy link
Collaborator

martinholmer commented Nov 5, 2016

Ten days ago @martinholmer said:

I honestly don't see a positive net benefit (that is, benefits minus development/maintenance costs) to using the [Python] logging module. If it could work inside the functions in the functions.py file, I would reconsider my assessment. But I assume the numba magic in those functions rules out the use of the Python logging module, right?

I'm assuming that no answer in ten days means the Python logging module would not be able to help with tracing the complex logic in the functions.py file. Also, there has been no objection in ten days to my proposal that issue #160 be closed.

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

4 participants