Skip to content

Commit

Permalink
Make errors in reST display in logs again
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 29, 2017
1 parent 05b1fd1 commit 6715f8d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -28,6 +28,7 @@ Features
Bugfixes
--------

* Make errors in reST display in logs again
* Unquote paths given to ``link://`` magic URLs (Issue #2934)
* Specify UTF-8 input encoding for Mako as default (Issue #2930)
* Don't trigger rebuilds in auto mode for files it's safe to ignore
Expand Down
29 changes: 18 additions & 11 deletions nikola/plugins/compile/rest/__init__.py
Expand Up @@ -28,6 +28,7 @@

import io
import os
import logbook.base

import docutils.core
import docutils.nodes
Expand Down Expand Up @@ -184,7 +185,7 @@ def set_site(self, site):

self.logger = get_logger('compile_rest')
if not site.debug:
self.logger.level = 4
self.logger.level = logbook.base.WARNING


def get_observer(settings):
Expand All @@ -194,17 +195,23 @@ def observer(msg):
Error code mapping:
+------+---------+------+----------+
| dNUM | dNAME | lNUM | lNAME | d = docutils, l = logbook
+------+---------+------+----------+
| 0 | DEBUG | 1 | DEBUG |
| 1 | INFO | 2 | INFO |
| 2 | WARNING | 4 | WARNING |
| 3 | ERROR | 5 | ERROR |
| 4 | SEVERE | 6 | CRITICAL |
+------+---------+------+----------+
+----------+----------+
| docutils | logbook |
+----------+----------+
| DEBUG | DEBUG |
| INFO | INFO |
| WARNING | WARNING |
| ERROR | ERROR |
| SEVERE | CRITICAL |
+----------+----------+
"""
errormap = {0: 1, 1: 2, 2: 4, 3: 5, 4: 6}
errormap = {
docutils.utils.Reporter.DEBUG_LEVEL: logbook.base.DEBUG,
docutils.utils.Reporter.INFO_LEVEL: logbook.base.INFO,
docutils.utils.Reporter.WARNING_LEVEL: logbook.base.WARNING,
docutils.utils.Reporter.ERROR_LEVEL: logbook.base.ERROR,
docutils.utils.Reporter.SEVERE_LEVEL: logbook.base.CRITICAL
}
text = docutils.nodes.Element.astext(msg)
line = msg['line'] + settings['add_ln'] if 'line' in msg else 0
out = '[{source}{colon}{line}] {text}'.format(
Expand Down

0 comments on commit 6715f8d

Please sign in to comment.