-
Notifications
You must be signed in to change notification settings - Fork 26
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
Use logging.info for ingest/outgest prints #186
Conversation
47f6b42
to
46da39b
Compare
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 is perfectly fine for scripts or more generally applications that have full control over logging. However it is not ideal for libraries that need to play well with others: the logging system if quite flexible so that the driver application can enable logging for library X1 at level L1 with handler(s) H1 and formatter F1, for library X2 at level L2 with handler(s) H2 and formatter F2, and so on.
To make it a well-behaved library, two things need to change:
- Replace the
logging.info
calls withlogger.info
, wherelogger
is alogging.Logger
instance. A common practice is to create one logger for each module (that needs to log anything):
import logging
logger = logging.getLogger(__name__)
- Remove the
logging.basicConfig
(or any kind of logging configuration for that matter) from the library. Configuration is the responsibility of the driver application, not an individual library. In this case this implies that theverbose
flag fromSOMA
andSOMACollection
should go.
Having said that, the library may configure logging in its entry points (e.g. CLI scripts), in this case fortools
andexamples
.
More about Python logging:
434c7e4
to
3b47714
Compare
80b500b
to
b122ebe
Compare
31866fe
to
7343f01
Compare
Also manually verified
ingestor -q
andoutgestor -q
are silent.