diff --git a/README.rst b/README.rst index 967744c..6afe379 100644 --- a/README.rst +++ b/README.rst @@ -87,7 +87,7 @@ Following parameters are needed to sign: Signing methods are really limited. Do not hesitate to contribute ! - Available: `none` (no encryption), `pkcs11` + Available: `none` (no signing), `pkcs11` To be implemented: `p12`, `gpg` diff --git a/build/lib/sphinx_weasyprint_builder/weasyprint_builder.py b/build/lib/sphinx_weasyprint_builder/weasyprint_builder.py index e8d5225..21d4c18 100644 --- a/build/lib/sphinx_weasyprint_builder/weasyprint_builder.py +++ b/build/lib/sphinx_weasyprint_builder/weasyprint_builder.py @@ -9,6 +9,10 @@ from sphinx.util.osutil import os_path from sphinx.locale import __ import weasyprint +from .loghandler import init_wpsphinx_log + + +init_wpsphinx_log() class WeasyPrintPDFBuilder(SingleFileHTMLBuilder): @@ -70,7 +74,5 @@ class WeasyPrintPDFBuilder(SingleFileHTMLBuilder): self.config.weasyprint_basename + '.pdf' ) weasy_html = weasyprint.HTML(infile) - print('*********************') - print('%s ----- %s', (infile, outfile)) weasy_html.write_pdf(outfile) # progress_message('Signing PDF') diff --git a/sphinx_weasyprint_builder/.__init__.py.swp b/sphinx_weasyprint_builder/.__init__.py.swp deleted file mode 100644 index 8d2b0a7..0000000 Binary files a/sphinx_weasyprint_builder/.__init__.py.swp and /dev/null differ diff --git a/sphinx_weasyprint_builder/.pdf_signing.py.swp b/sphinx_weasyprint_builder/.pdf_signing.py.swp deleted file mode 100644 index 1025c57..0000000 Binary files a/sphinx_weasyprint_builder/.pdf_signing.py.swp and /dev/null differ diff --git a/sphinx_weasyprint_builder/.weasyprint_builder.py.swp b/sphinx_weasyprint_builder/.weasyprint_builder.py.swp index 874dd73..a6ca338 100644 Binary files a/sphinx_weasyprint_builder/.weasyprint_builder.py.swp and b/sphinx_weasyprint_builder/.weasyprint_builder.py.swp differ diff --git a/sphinx_weasyprint_builder/loghandler.py b/sphinx_weasyprint_builder/loghandler.py new file mode 100644 index 0000000..a5d2bc8 --- /dev/null +++ b/sphinx_weasyprint_builder/loghandler.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +import logging +from sphinx.util import logging as sphinx_logging + + +logger = sphinx_logging.getLogger('weasyprint_builder') + + +def init_wpsphinx_log(): + """ + Initialize logging for WeasyPrint. + """ + wplogger = logging.getLogger('weasyprint') + wphandler = SphinxWPHandler() + wphandler.setLevel(logging.INFO) + formatter = logging.Formatter('%(message)s') + wphandler.setFormatter(formatter) + wplogger.addHandler(wphandler) + + +class SphinxWPHandler(logging.StreamHandler): + """ + Resend WeasyPrint logging to Sphinx output. + """ + def __init__(self): + super(SphinxWPHandler, self).__init__() + + def emit(self, record): + logger.handle(record) diff --git a/sphinx_weasyprint_builder/weasyprint_builder.py b/sphinx_weasyprint_builder/weasyprint_builder.py index e8d5225..21d4c18 100644 --- a/sphinx_weasyprint_builder/weasyprint_builder.py +++ b/sphinx_weasyprint_builder/weasyprint_builder.py @@ -9,6 +9,10 @@ from sphinx.util.osutil import os_path from sphinx.locale import __ import weasyprint +from .loghandler import init_wpsphinx_log + + +init_wpsphinx_log() class WeasyPrintPDFBuilder(SingleFileHTMLBuilder): @@ -70,7 +74,5 @@ class WeasyPrintPDFBuilder(SingleFileHTMLBuilder): self.config.weasyprint_basename + '.pdf' ) weasy_html = weasyprint.HTML(infile) - print('*********************') - print('%s ----- %s', (infile, outfile)) weasy_html.write_pdf(outfile) # progress_message('Signing PDF')