Skip to content
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

refs Kozea#412 Avoid default Logger #804

Merged
merged 1 commit into from
Feb 15, 2019
Merged

Conversation

xusy2k
Copy link
Contributor

@xusy2k xusy2k commented Feb 15, 2019

If you want to use Weasyprint under django, you can configure
weasyprint's logger via django, but this setting never is set

If you want to use Weasyprint under django, you can configure
weasyprint's logger via django, but this setting never is set
@liZe
Copy link
Member

liZe commented Feb 15, 2019

Thank you for this pull request.

I'm not sure to fully understand how this can a problem with Django. Could you please provide a simple example showing the problem you're fixing?

@xusy2k
Copy link
Contributor Author

xusy2k commented Feb 15, 2019

Yes: Django allows to configure logger. This is mine:

# settings.LOGGING:
LOGGING = {
 'disable_existing_loggers': False,
 'formatters': {'verbose': {'datefmt': '%Y%m%d %H:%M:%S',
                            'format': '[%(asctime)s] %(levelname)s '
                                      '[%(name)s:%(lineno)s] %(message)s'}},
 'handlers': {'console': {'class': 'logging.StreamHandler',
                          'formatter': 'verbose',
                          'level': 'DEBUG'},
              'file': {'class': 'logging.FileHandler',
                       'filename': '/tmp/logging.log',
                       'formatter': 'verbose',
                       'level': 'DEBUG'}},
 'loggers': {
             # ...
             'weasyprint': {'handlers': ['console'],
                            'level': 'ERROR',
                            'propagate': True},
             ,
            }
 'root': {'handlers': ['file'], 'level': 'DEBUG'},
 'version': 1
}

As you can see, I set default logLevel for weasyprint as ERROR, but this has no effect because the package set always logLevel to WARNING ignoring the django's setting.

In my case I have thousands of warnings like Error: Expected <ident> for declaration name, got literal. at 9:91136 taken from CSS (tested with Bootstrap 2.3.2). Also, I can't modify bootstrap.css, but I want to mute this warnings configuring the logLevel as ERROR

I hope this help you :-) and Thank you for this awesome package!

@liZe
Copy link
Member

liZe commented Feb 15, 2019

As you can see, I set default logLevel for weasyprint as ERROR, but this has no effect because the package set always logLevel to WARNING ignoring the django's setting.

OK, I can understand now. Thanks a lot for the example.

I hope this help you :-) and Thank you for this awesome package!

❤️

@liZe liZe merged commit 62d8f7f into Kozea:master Feb 15, 2019
@liZe liZe added this to the 45 milestone Feb 20, 2019
netbsd-srcmastr referenced this pull request in NetBSD/pkgsrc Feb 21, 2019
Version 45
----------

Released on 2019-02-20.

WeasyPrint now has a `code of conduct
<https://github.com/Kozea/WeasyPrint/blob/master/CODE_OF_CONDUCT.rst>`_.

A new website has been launched, with beautiful and useful graphs about speed
and memory use across versions: check `WeasyPerf
<https://kozea.github.io/WeasyPerf/index.html>`_.

Dependencies:

* Python 3.5+ is now needed, Python 3.4 is not supported anymore

Bug fixes:

* `798 <https://github.com/Kozea/WeasyPrint/pull/798>`_:
  Prevent endless loop and index out of range in pagination
* `767 <https://github.com/Kozea/WeasyPrint/issues/767>`_:
  Add a ``--quiet`` CLI parameter
* `784 <https://github.com/Kozea/WeasyPrint/pull/784>`_:
  Fix library loading on Alpine
* `791 <https://github.com/Kozea/WeasyPrint/pull/791>`_:
  Use path2url in tests for Windows
* `789 <https://github.com/Kozea/WeasyPrint/pull/789>`_:
  Add LICENSE file to distributed sources
* `788 <https://github.com/Kozea/WeasyPrint/pull/788>`_:
  Fix pending references
* `780 <https://github.com/Kozea/WeasyPrint/issues/780>`_:
  Don't draw patterns for empty page backgrounds
* `774 <https://github.com/Kozea/WeasyPrint/issues/774>`_:
  Don't crash when links include quotes
* `637 <https://github.com/Kozea/WeasyPrint/issues/637>`_:
  Fix a problem with justified text
* `763 <https://github.com/Kozea/WeasyPrint/pull/763>`_:
  Launch tests with Python 3.7
* `704 <https://github.com/Kozea/WeasyPrint/issues/704>`_:
  Fix a corner case with tables
* `804 <https://github.com/Kozea/WeasyPrint/pull/804>`_:
  Don't logger handlers defined before importing WeasyPrint
* `109 <https://github.com/Kozea/WeasyPrint/issues/109>`_,
  `748 <https://github.com/Kozea/WeasyPrint/issues/748>`_:
  Don't include punctuation for hyphenation
* `770 <https://github.com/Kozea/WeasyPrint/issues/770>`_:
  Don't crash when people use uppercase words from old-fashioned Microsoft
  fonts in tables, especially when there's an 5th column
* Use a `separate logger
  <https://weasyprint.readthedocs.io/en/latest/tutorial.htmllogging>`_ to
  report the rendering process
* Add a ``--debug`` CLI parameter and set debug level for unknown prefixed CSS
  properties
* Define minimal versions of Python and setuptools in setup.cfg

Documentation

* `796 <https://github.com/Kozea/WeasyPrint/pull/796>`_:
  Fix a small typo in the tutorial
* `792 <https://github.com/Kozea/WeasyPrint/pull/792>`_:
  Document no alignement character support
* `773 <https://github.com/Kozea/WeasyPrint/pull/773>`_:
  Fix phrasing in Hacking section
* `402 <https://github.com/Kozea/WeasyPrint/issues/402>`_:
  Add a paragraph about fontconfig error
* `764 <https://github.com/Kozea/WeasyPrint/pull/764>`_:
  Fix list of dependencies for Alpine
* Fix API documentation of HTML and CSS classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants