Logging¶
entrezpy uses the Python logging module for logging. The base
classes do only log the levels ‘ERROR’ and ‘DEBUG’. The module
entrezpy.log.logger
contains all methods related to logging. A basic
configuration of the logger is given in entrezpy.log.conf
.
Applications using entrezpy can set the level of logging as shown in
(Listing 19). Logging calls can be made in classes inheriting
entrezpy classes as shown in (Listing 20). The
entrezpy.log.logger.get_class_logger()
required the class as its input.
Add logging to applications using entrezpy
¶
Importing the logging module and set the level.
1 2 3 4 5 6 7 8 | import entrezpy.log.logger
entrezpy.log.logger.set_level('DEBUG')
def main():
"""
your application using entrezpy
"""
|
Add logging to a class inheriting a entrezpy
base class¶
1 2 3 4 5 6 7 8 9 10 | import entrezpy.log.logger
class Esearcher(entrezpy.base.query.EutilsQuery):
def __init__(self, tool, email, apikey=None, apikey_var=None, threads=None, qid=None):
super().__init__('esearch.fcgi', tool, email, apikey=apikey, threads=threads, qid=qid)
self.logger = entrezpy.log.logger.get_class_logger(Esearcher)
self.logger.debug(json.dumps({'init':self.dump()}))
|