Commits

Anonymous committed 3768906

Make a simple logbook setup

  • Participants
  • Parent commits 79ecde1

Comments (0)

Files changed (1)

File sphinx/application.py

 from docutils.parsers.rst import convert_directive_function, \
      directives, roles
 
+from logbook import Logger, NestedSetup, NullHandler, StreamHandler
+from logbook.more import ExceptionHandler
+
 import sphinx
 from sphinx import package_dir, locale
 from sphinx.roles import XRefRole
         self.outdir = outdir
         self.doctreedir = doctreedir
 
+        self.log = Logger('Sphinx')
         if status is None:
             self._status = StringIO()
             self.quiet = True
         else:
             self._status = status
             self.quiet = False
-
         if warning is None:
             self._warning = StringIO()
         else:
             self._warning = warning
+        self.warningiserror = warningiserror
         self._warncount = 0
-        self.warningiserror = warningiserror
+        handlers = [
+            NullHandler(),
+            StreamHandler(self._status, level='INFO'),
+            StreamHandler(self._warning, level='WARNING', bubble=True)
+        ]
+        if warningiserror:
+            handlers.append(ExceptionHandler(SphinxWarning, level='warning',
+                                             bubble=True))
+        self.log_handler = NestedSetup(handlers)
+        self.log_handler.push_application()
 
         self._events = events.copy()