![]() |
#1 |
Connoisseur
![]() 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
|
![]()
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') 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'} 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: |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,584
Karma: 14328510
Join Date: Nov 2019
Device: none
|
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.
|
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() 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
|
![]()
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. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |