View Single Post
Old 02-19-2021, 04:03 PM   #1
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 96
Karma: 40
Join Date: Mar 2020
Location: Belgium (sorry, I am from the Walloon side of the country and I speak french only)
Device: PW3, Kobo Libra H2O
Question Difference between log.debug, log.info, log.warn log.error

I want to learn python so I decided to write something challenging.

In order to implement a new source object (noosfere) under calibre 5.11, I have used heavily the log.info()...
Then, I have discovered that log.error existed... but I could not see any difference in the log file...

I traced the log back to logging.py. I failed to understand really what to expect when invoking log.debug or log.info or log.error

I have the feeling that some differences should exist, I would expect something like [ERROR] in front of a line output by log.error.

So, is what I see the expected?

the code is:
Code:
    def identify(self, log, result_queue, abort, title=None, authors=None, identifiers={}, timeout=30):
        log.debug('\nEntering identify(self, log, result_queue, abort, title=None, authors=None,identifiers={}, timeout=30)')
        log.info('log          : ', log)
        log.error('result_queue : ', result_queue)
        log.info('abort        : ', abort)
        log.info('title        : ', title)
        log.info('authors      : ', authors, type(authors))
        log.info('identifiers  : ', identifiers)
        log.info('\n')
The result shows no differences between the 3 first lines of output
Code:
Entering identify(self, log, result_queue, abort, title=None, authors=None,identifiers={}, timeout=30)
log          :  <calibre.utils.logging.ThreadSafeLog object at 0x000001D37BA784C0>
result_queue :  <queue.Queue object at 0x000001D37BA78A90>
abort        :  <threading.Event object at 0x000001D37BA784F0>
title        :  Le Printemps d'Helliconia
authors      :  ['B.W. Aldiss'] <class 'list'>
identifiers  :  {'isbn': '2-221-10703-9'}
Please note that the code was extracted from my __init__.py and the result was gained using the test section...

Code:
if __name__ == '__main__':
    
    # Run these tests from the directory contatining all files needed for the plugin
    # that is, __init__.py, plugin-import-name-noosfere.txt and optional worker.py, ui.py
    # issue in sequence:
    # calibre-customize -b .
    # calibre-debug -e __init__.py
    
    from calibre.ebooks.metadata.sources.test import (test_identify_plugin, title_test, authors_test, series_test)
    test_identify_plugin(noosfere.name,
        [

            ( # A book with an ISBN
                {'identifiers':{'isbn': '2-221-10703-9'},
                    'title':"Le Printemps d'Helliconia", 'authors':['B.W. Aldiss']},
                [title_test("Le Printemps d'Helliconia",
                    exact=True), authors_test(['Brian Aldiss']),
                    series_test('Helliconia', 1.0)]

            ),

        ])

The complete code is available on github
https://github.com/lrpirlet/cal-noosfere

Last edited by lrpirlet; 02-19-2021 at 04:20 PM. Reason: I forgot a, maybe, important information:
lrpirlet is offline   Reply With Quote