Changeset - b074edc538b6
[Not reviewed]
0 1 0
Brett Smith - 3 years ago 2021-01-09 15:09:45
brettcsmith@brettcsmith.org
cliutil: Set floor for pdfminer loglevel.
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/cliutil.py
Show inline comments
...
 
@@ -367,28 +367,29 @@ def setup_logger(logger: Union[str, logging.Logger]='',
 
    return logger
 

	
 
def set_loglevel(logger: logging.Logger, loglevel: int=logging.INFO) -> None:
 
    """Set the loglevel for a tool or module
 

	
 
    If the given logger is not under a hierarchy, this function sets the
 
    loglevel for the root logger, along with some specific levels for libraries
 
    used by reporting tools. Otherwise, it's the same as
 
    ``logger.setLevel(loglevel)``.
 
    """
 
    if '.' not in logger.name:
 
        logger = logging.getLogger()
 
        if loglevel <= logging.DEBUG:
 
            # At the debug level, the rt module logs the full body of every
 
            # request and response. That's too much.
 
            logging.getLogger('rt.rt').setLevel(logging.INFO)
 
        # pdfminer logs debug-like messages at the info level
 
        logging.getLogger('pdfminer').setLevel(max(loglevel, logging.WARNING))
 
        # At the debug level, the rt module logs the full body of every
 
        # request and response. That's too much.
 
        logging.getLogger('rt.rt').setLevel(max(loglevel, logging.INFO))
 
    logger.setLevel(loglevel)
 

	
 
def bytes_output(path: Optional[Path]=None,
 
                 default: OutputFile=sys.stdout,
 
                 mode: str='w',
 
) -> BinaryIO:
 
    """Get a file-like object suitable for binary output
 

	
 
    If ``path`` is ``None`` or ``-``, returns a file-like object backed by
 
    ``default``. If ``default`` is a file descriptor or text IO object, this
 
    method returns a file-like object that writes to the same place.
 

	
0 comments (0 inline, 0 general)