[hawkmoth] Re: [PATCH 1/4] hawkmoth: use Sphinx method of logging

  • From: Jani Nikula <jani@xxxxxxxxxx>
  • To: Bruno Manuel Baraças dos Santos <brunomanuelsantos@xxxxxxxxxxxxxxxxxx>, hawkmoth mailing list <hawkmoth@xxxxxxxxxxxxx>
  • Date: Sun, 28 Apr 2019 21:41:53 +0300

On Sun, 28 Apr 2019, Bruno Manuel Baraças dos Santos 
<brunomanuelsantos@xxxxxxxxxxxxxxxxxx> wrote:

Newer version of sphinx says it is deprecated.

Thanks. Pushed, with "it" above clarified.

BR,
Jani.


Signed-off-by: Marius Vlad <marius.vlad@xxxxxxxxxxxxx>
---
 hawkmoth/__init__.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hawkmoth/__init__.py b/hawkmoth/__init__.py
index 7913014..3355922 100644
--- a/hawkmoth/__init__.py
+++ b/hawkmoth/__init__.py
@@ -19,6 +19,7 @@
 from docutils.statemachine import ViewList
 from sphinx.util.nodes import nested_parse_with_titles
 from sphinx.util.docutils import switch_source_input
+from sphinx.util import logging
 
 from hawkmoth.parser import parse
 
@@ -30,6 +31,7 @@ class CAutoDocDirective(Directive):
     """Extract all documentation comments from the specified file"""
     required_argument = 1
     optional_arguments = 1
+    logger = logging.getLogger(__name__)
 
     # Allow passing a variable number of file patterns as arguments
     final_argument_whitespace = True
@@ -65,16 +67,16 @@ def run(self):
             filenames = glob.glob(env.config.cautodoc_root + '/' + pattern)
             if len(filenames) == 0:
                 fmt = 'Pattern "{pat}" does not match any files.'
-                env.app.warn(fmt.format(pat=pattern),
-                             location=(env.docname, self.lineno))
+                self.logger.warning(fmt.format(pat=pattern),
+                                    location=(env.docname, self.lineno))
                 continue
 
             for filename in filenames:
                 mode = os.stat(filename).st_mode
                 if stat.S_ISDIR(mode):
                     fmt = 'Path "{name}" matching pattern "{pat}" is a 
directory.'
-                    env.app.warn(fmt.format(name=filename, pat=pattern),
-                                 location=(env.docname, self.lineno))
+                    self.logger.warning(fmt.format(name=filename, 
pat=pattern),
+                                        location=(env.docname, self.lineno))
                     continue
 
                 # Tell Sphinx about the dependency and parse the file
-- 
2.21.0

Other related posts: