-
Notifications
You must be signed in to change notification settings - Fork 66
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
Issue 464 logger instead of print #499
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
It works exactly the same whether you use nansat alone or with geospaas_harvesting: the "Nansat" logger is created when If you are going to use |
@aperrin66 done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good!
But I don;t see that logging.config
, os.path
or yaml
is used in __init__.py
why did you add that?
If it is not used, can you remove it?
formatter = logging.Formatter('%(asctime)s - %(name)s - %(threadName)s - ' | ||
'%(levelname)s - %(message)s') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the threadName field, nansat is single-threaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually is there any need to change the format at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to make it in a unified format when we start the process from harvesting, this helps to read the logs easily,all levels of nansat,harvesting and run_container.py MUST have same format of log. Because they are unified when call from each other. Reading logs with different format is difficult. so it is better to keep it. The thread is unknown, or sth like that,it does not matter, let it be.
nansat/nansat.py
Outdated
@@ -1585,7 +1585,7 @@ def _import_mappers(log_level=None): | |||
value: class Mapper(VRT) from the mappers module | |||
|
|||
""" | |||
logger = add_logger('import_mappers', logLevel=log_level) | |||
logger = add_logger('Nansat', logLevel=log_level) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is not part of the Nansat
class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it is in nansat repository.DO you have any other name in your mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either leave it as it was or use something like nansat.import_mappers
.
Note: nansat
refers to the package. Nansat
refers to the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
nansat/mappers/mapper_aapp_l1b.py
Outdated
|
||
from nansat.exceptions import WrongMapperError | ||
from nansat.geolocation import Geolocation | ||
from nansat.vrt import VRT | ||
|
||
LOGGER = logging.getLogger("Nansat."+__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__name__
already contains the full name of the module (here, it isnansat.mappers.mapper_aapp_l1b
), so there is no need to prefix it with "Nansat.".
Same thing for the other mappers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you are right! But, when we run it from harvesting, only mapper_aapp_l1b
is appear! It is better to keep that in the name of the lagger,isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then write the full module name (nansat.mappers.mapper_aapp_l1b
), that way there is no ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
No description provided.