nansencenter / nansat

Scientist friendly Python toolbox for processing 2D satellite Earth observation data.
http://nansat.readthedocs.io
GNU General Public License v3.0
182 stars 66 forks source link

Issue 464 logger instead of print #499

Open opsdep opened 3 years ago

opsdep commented 3 years ago

You need to choose one way to configure logging:

  • either use the current mechanism with logger attributes defined for each object using nansat.utils.add_logger
  • or use a global logging configuration initialized in nansat.__init__

No we need both of them because the run can be started with nansat usage as standalone (in that case, we need nansat.__init__ ), and as the second case when we run the harvesting, the nansat.utils.add_logger function configures the logger when it is needed.

aperrin66 commented 3 years ago

You need to choose one way to configure logging:

  • either use the current mechanism with logger attributes defined for each object using nansat.utils.add_logger
  • or use a global logging configuration initialized in nansat.__init__

No we need both of them because the run can be started with nansat usage as standalone (in that case, we need nansat.__init__ ), and as the second case when we run the harvesting, the nansat.utils.add_logger function configures the logger when it is needed.

It works exactly the same whether you use nansat alone or with geospaas_harvesting: the "Nansat" logger is created when nansat is imported, then the log level is overridden when add_logger is called (for example when a Nansat object is instantiated).

If you are going to use add_logger, you might as well put the whole logging configuration in there. It will be less confusing than having the configuration in logging.yml and then overriding the log level when add_logger is called.

opsdep commented 3 years ago

@aperrin66 done