Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 02-19-2021, 04:03 PM   #1
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 94
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
Old 02-19-2021, 06:01 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,252
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
log.error() will automatically print a traceback if an exception has occurred. Other than that you may or may not see a difference depending on the type of logging backend used.
kovidgoyal is offline   Reply With Quote
Advert
Old 02-19-2021, 07:21 PM   #3
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,584
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by lrpirlet View Post
I have the feeling that some differences should exist, I would expect something like [ERROR] in front of a line output by log.error.
As I remember that's what log4j etc. would do. There's probably some simple way to fix python's logging to prepend the levels automatically.
hobnail is offline   Reply With Quote
Old 02-20-2021, 03:43 AM   #4
lrpirlet
Connoisseur
lrpirlet began at the beginning.
 
Posts: 94
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
Smile

OK, no problem then, I'll continue using log.info everywhere unless I report a potential error in witch case I'll use log.error.

Thanks.
lrpirlet is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Content Server -- access log info Ginnia Library Management 5 09-12-2017 06:07 AM
[Android] Calibre companion debug log waldoB Calibre Companion 4 12-27-2016 08:35 AM
wifi to Kindle does not work; debug log as requested solin111 Devices 0 02-13-2013 10:39 PM
Does anyone know how to read a Calibre debug log file? TomOnMobread Calibre 7 12-11-2012 01:57 PM
calibre 0.7.48 error log winterescape Calibre 4 03-11-2011 05:24 PM


All times are GMT -4. The time now is 08:53 PM.


MobileRead.com is a privately owned, operated and funded community.