Send WeasyPrint logs to Sphinx logger
This commit is contained in:
parent
76baca06b4
commit
441ec2418e
7 changed files with 39 additions and 5 deletions
|
@ -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`
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
30
sphinx_weasyprint_builder/loghandler.py
Normal file
30
sphinx_weasyprint_builder/loghandler.py
Normal file
|
@ -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)
|
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue