Skip to content
Permalink
Browse files

Make errors in reST display in logs again

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 29, 2017
1 parent 05b1fd1 commit 6715f8d902aea8c789bf0ad0c0bbbf9f207216c0
Showing with 19 additions and 11 deletions.
  1. +1 −0 CHANGES.txt
  2. +18 −11 nikola/plugins/compile/rest/__init__.py
@@ -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
@@ -28,6 +28,7 @@

import io
import os
import logbook.base

import docutils.core
import docutils.nodes
@@ -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):
@@ -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(

0 comments on commit 6715f8d

Please sign in to comment.