kingjml / pySnowRadar

Snow radar data processing and snow depth retrieval
MIT License
8 stars 3 forks source link

replace print with logger #33

Closed m9brady closed 4 years ago

m9brady commented 4 years ago

Basically replaces print statements with logging messages that are off by default.

>>> from pySnowRadar import SnowRadar
>>> x = SnowRadar('./path/to/data', l_case='full')
>>> x.as_dict()
{ fname: 'data', ... }

No log messages on SnowRadar object init ☝️

It is up to the user to add a handler in order to see log messages in stdout/stderr, which can be accomplished as follows:

>>> import logging
>>> logger = logging.getLogger('pySnowRadar')
>>> sh = logging.StreamHandler()
>>> fmt = logging.Formatter('%(asctime)s | %(name)s | %(message)s', '%Y-%m-%d %H:%M:%S')
>>> sh.addFormatter(fmt)
>>> logger.addHandler(sh)
>>> logger.setLevel(logging.DEBUG) # SnowRadar object init log message is debug-level
>>> x = SnowRadar('./path/to/data', l_case='full')
2077-01-01 12:15:00 | pySnowRadar.snowradar | Loading: data (full)