New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weasyprint logging is missconfigured #412

Closed
PamelaM opened this Issue Jan 18, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@PamelaM

PamelaM commented Jan 18, 2017

From the python docs https://docs.python.org/2/howto/logging.html#library-config :

Note It is strongly advised that you do not add any handlers other than NullHandler to your 
library’s loggers. This is because the configuration of handlers is the prerogative of the 
application developer who uses your library. The application developer knows their target 
audience and what handlers are most appropriate for their application: if you add handlers 
‘under the hood’, you might well interfere with their ability to carry out unit tests and 
deliver logs which suit their requirements.

The default handler should be the NullHandler.

@liZe liZe added the feature label Jan 18, 2017

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 18, 2017

Member

I agree. Silent logs have been asked before (at least #300 and #312) and that should be the default when WeasyPrint used as a library. We should log to stderr only when it's the "normal" way to handle logs, i.e. when WeasyPrint is launched from the CLI.

Member

liZe commented Jan 18, 2017

I agree. Silent logs have been asked before (at least #300 and #312) and that should be the default when WeasyPrint used as a library. We should log to stderr only when it's the "normal" way to handle logs, i.e. when WeasyPrint is launched from the CLI.

@PamelaM

This comment has been minimized.

Show comment
Hide comment
@PamelaM

PamelaM Jan 18, 2017

For those hitting this problem before it's fixed, here's how I've disabled the weasyprint logging handler - the logger needs to be set up before the first import of weasyprint

import logging

logger = logging.getLogger("weasyprint")
if not logger.handlers:
    logger.addHandler(logging.NullHandler())

from weasyprint import HTML

PamelaM commented Jan 18, 2017

For those hitting this problem before it's fixed, here's how I've disabled the weasyprint logging handler - the logger needs to be set up before the first import of weasyprint

import logging

logger = logging.getLogger("weasyprint")
if not logger.handlers:
    logger.addHandler(logging.NullHandler())

from weasyprint import HTML
@erichonkanen

This comment has been minimized.

Show comment
Hide comment
@erichonkanen

erichonkanen Mar 20, 2017

possibly related, I think all of the WARNING messages are coming from this package?

image

erichonkanen commented Mar 20, 2017

possibly related, I think all of the WARNING messages are coming from this package?

image

@liZe liZe added this to the v0.37 milestone Mar 24, 2017

@liZe liZe closed this in 210b738 Mar 24, 2017

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Aug 1, 2017

kleink
Update py-weasyprint to 0.39.
Version 0.39
------------

Released on 2017-06-24.

Bug fixes:

* Fix the use of WeasyPrint's URL fetcher with CairoSVG.


Version 0.38
------------

Released on 2017-06-16.

Bug fixes:

* `#477 <https://github.com/Kozea/WeasyPrint/issues/477>`_:
  Don't crash on font-face's src attributes with local functions.


Version 0.37
------------

Released on 2017-06-15.

WeasyPrint now depends on tinycss2 instead of tinycss.

New features:

* `#437 <https://github.com/Kozea/WeasyPrint/issues/437>`_:
  Support local links in generated PDFs.

Bug fixes:

* `#412 <https://github.com/Kozea/WeasyPrint/issues/412>`_:
  Use a NullHandler log handler when WeasyPrint is used as a library.
* `#417 <https://github.com/Kozea/WeasyPrint/issues/417>`_,
  `#472 <https://github.com/Kozea/WeasyPrint/issues/472>`_:
  Don't crash on some line breaks.
* `#327 <https://github.com/Kozea/WeasyPrint/issues/327>`_:
  Don't crash with replaced elements with height set in percentages.
* `#467 <https://github.com/Kozea/WeasyPrint/issues/467>`_:
  Remove incorrect line breaks.
* `#446 <https://github.com/Kozea/WeasyPrint/pull/446>`_:
  Let the logging module do the string interpolation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment