Using this trivial plugin:
Code:
from calibre.customize.conversion import InputFormatPlugin
class TestInput(InputFormatPlugin):
name = "TestIt Input"
author = "me"
version = (1, 0, 0)
minimum_calibre_version = (2, 0, 0)
supported_platforms = ["windows", "osx", "linux"]
description = "Test logging"
file_types = {"foo",}
def __init__(self, *args, **kwargs):
InputFormatPlugin.__init__(self, *args, **kwargs)
print('here in TestInput')
def convert(self, stream, options, file_ext, log, accelerators):
print('Hi There printed')
log.error("Hi There tp log.error")
raise ValueError('my exception')
I get this output when I attempt to convert a .FOO document to EPUB using the convert button.
Spoiler:
Convert book 1 of 1 (doc)
here in TestInput
Conversion options changed from defaults:
read_metadata_from_opf: 'C:\\Users\\Charles\\AppData\\Local\\Temp\\calibre _2i3y7vaf\\x94g4ylx.opf'
verbose: 2
output_profile: 'tablet'
Resolved conversion options
calibre version: 6.14.0
{'asciiize': False,
***CLIP***
}
InputFormatPlugin: TestIt Input running
on C:\Users\Charles\AppData\Local\Temp\calibre_2i3y7v af\e7fujkl_.foo
Hi There printed
Hi There tp log.error
Traceback (most recent call last):
File "runpy.py", line 196, in _run_module_as_main
File "runpy.py", line 86, in _run_code
File "site.py", line 83, in <module>
File "site.py", line 78, in main
File "site.py", line 50, in run_entry_point
File "calibre\utils\ipc\worker.py", line 215, in main
File "calibre\gui2\convert\gui_conversion.py", line 38, in gui_convert_override
File "calibre\gui2\convert\gui_conversion.py", line 25, in gui_convert
File "calibre\ebooks\conversion\plumber.py", line 1108, in run
File "calibre\customize\conversion.py", line 242, in __call__
File "calibre_plugins.TestInput.__init__", line 20, in convert
ValueError: my exception
Both the print and the log.error() messages are there.
The call on import by FTS to get the text does seem to throw away the logs, but you can debug the plugin using convert.