44from typing import Union
55from typing import Generator
66
7- import logging
87import os
98import re
109import subprocess
1413import glob
1514from pathlib import Path
1615
17- from .handler import _check_log_handler
16+ from .handler import logger , _check_log_handler
1817from .pandoc_download import DEFAULT_TARGET_FOLDER , download_pandoc
1918from .py3compat import cast_bytes , cast_unicode , string_types , url2path , urlparse
2019
2120__author__ = u'Juho Vepsäläinen'
2221__author_email__ = "bebraw@gmail.com"
22+ __maintainer__ = u'Jessica Tegner'
2323__url__ = 'https://github.com/JessicaTegner/pypandoc'
2424__version__ = '1.10'
2525__license__ = 'MIT'
5151 'get_pandoc_formats' , 'get_pandoc_version' , 'get_pandoc_path' ,
5252 'download_pandoc' ]
5353
54- # Set up the module level logger
55- logger = logging .getLogger (__name__ )
56-
5754def convert_text (source :str , to :str , format :str , extra_args :Iterable = (), encoding :str = 'utf-8' ,
5855 outputfile :Union [None , str , Path ]= None , filters :Union [Iterable , None ]= None , verify_format :bool = True ,
5956 sandbox :bool = False , cworkdir :Union [str , None ]= None ) -> str :
@@ -322,14 +319,18 @@ def _convert_input(source, format, input_type, to, extra_args=(),
322319 sandbox = False , cworkdir = None ):
323320
324321 _check_log_handler ()
322+
323+ logger .debug ("Ensuring pandoc path..." )
325324 _ensure_pandoc_path ()
326325
327326 if verify_format :
327+ logger .debug ("Verifying format..." )
328328 format , to = _validate_formats (format , to , outputfile )
329329 else :
330330 format = normalize_format (format )
331331 to = normalize_format (to )
332332
333+ logger .debug ("Identifying input type..." )
333334 string_input = input_type == 'string'
334335 if not string_input :
335336 if isinstance (source , str ):
@@ -351,7 +352,10 @@ def _convert_input(source, format, input_type, to, extra_args=(),
351352
352353 if sandbox :
353354 if ensure_pandoc_minimal_version (2 ,15 ): # sandbox was introduced in pandoc 2.15, so only add if we are using 2.15 or above.
355+ logger .debug ("Adding sandbox argument..." )
354356 args .append ("--sandbox" )
357+ else :
358+ logger .warning ("Sandbox argument was used, but pandoc version is too low. Ignoring argument." )
355359
356360 args .extend (extra_args )
357361
@@ -373,6 +377,7 @@ def _convert_input(source, format, input_type, to, extra_args=(),
373377 if cworkdir and old_wd != cworkdir :
374378 os .chdir (cworkdir )
375379
380+ logger .debug ("Running pandoc..." )
376381 p = subprocess .Popen (
377382 args ,
378383 stdin = subprocess .PIPE if string_input else None ,
@@ -702,7 +707,7 @@ def _ensure_pandoc_path() -> None:
702707 # path exist but is not useable -> not executable?
703708 log_msg = ("Found {}, but not using it because of an "
704709 "error:" .format (path ))
705- logging .exception (log_msg )
710+ logger .exception (log_msg )
706711 continue
707712 version = [int (x ) for x in version_string .split ("." )]
708713 while len (version ) < len (curr_version ):
0 commit comments