PyKrige icon indicating copy to clipboard operation
PyKrige copied to clipboard

implement logging throughout

Open basaks opened this issue 9 years ago • 5 comments

Use the logging module everywhere, instead of print statement everywhere? Make this part of next release?

basaks avatar Dec 21 '16 05:12 basaks

Yeah, this is a really good idea. Maybe we could implement an option for no output, printed output, or log output. Definitely something good for v2.

bsmurphy avatar Dec 21 '16 23:12 bsmurphy

@basaks I'm not sure about this. Wouldn't just printing and rasing warning be enough? And then let logging be handled by the user application?

For instance, numpy, scipy, scikit-learn don't use the logging module in the core library, which allows more flexibility for the end user to use this logging module or not in their code and also keeps things simpler...

rth avatar Mar 01 '17 11:03 rth

Well, the logging module allows great flexibility and makes things easier. You can choose an arbitrary name, e.g. logging.getLogger("bsmurphy/PyKrige") and then disable propagation. That way you will never interfere with whatever choices the end user does for their application. But the end user can choose what they want to log and where it should be logged. Printing the output is a less-favorable solution because unlike logging it is not possible for the end user to control the output at a later stage.

1kastner avatar Aug 18 '17 08:08 1kastner

@1kastner I see your point. For reporting "events that occur during normal operation of a program" cf logging docs that currently use print when verbose=True this would indeed be better. For warnings though, warnings.warn might be more appropriate. Pull Requests welcome )

rth avatar Aug 18 '17 09:08 rth

I agree that warnings.warn is more suitable than logging.warning in this context.

1kastner avatar Aug 18 '17 09:08 1kastner