How to use the loguru.logger.catch function in loguru

To help you get started, we’ve selected a few loguru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Delgan / loguru / tests / exceptions / source / backtrace / chaining_third.py View on Github external
def b_context_manager():
    with logger.catch():
        c_not_decorated()
github Delgan / loguru / tests / test_exceptions.py View on Github external
def f(n):
            with logger.catch(message=""):
                if n:
                    f(n - 1)
                n / 0
github Python3WebSpider / ProxyPool / proxypool / crawlers / base.py View on Github external
    @logger.catch
    def crawl(self):
        """
        crawl main method
        """
        for url in self.urls:
            logger.info(f'fetching {url}')
            html = self.fetch(url)
            for proxy in self.parse(html):
                logger.info(f'fetched proxy {proxy.string()} from {url}')
                yield proxy
github quanhua92 / downsampled-open-images-v4 / image_resizer.py View on Github external
@logger.catch
def resize_images(idx, filenames, in_dir, out_dir, algo, size, extension, log_path, verbose):
    logger.add(log_path, enqueue=True)

    logger.info("Thread {} starts!", idx)

    count_error = 0
    for file_idx, filename in enumerate(filenames):    
        if file_idx % verbose == 0:
            logger.info("Thread {} processed {}/{}", idx, file_idx, len(filenames))

        in_path = os.path.join(in_dir, filename)
        if len(extension) > 0:
            name, _ = os.path.splitext(filename)
            out_path = os.path.join(out_dir, name + "." + extension)
        else:
            out_path = os.path.join(out_dir, filename)