How to use the loguru.logger.configure 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 / test_configure.py View on Github external
def test_levels(writer):
    levels = [{"name": "my_level", "icon": "X", "no": 12}, {"name": "DEBUG", "icon": "!"}]

    logger.add(writer, format="{level.no}|{level.name}|{level.icon}|{message}")
    logger.configure(levels=levels)

    logger.log("my_level", "test")
    logger.debug("no bug")

    assert writer.read() == ("12|my_level|X|test\n" "10|DEBUG|!|no bug\n")
github brandonskerritt / Ciphey / tests / test_encoding.py View on Github external
def test_morse(self):
        lc = Brandon(config)
        ep = EncodingParent(lc)
        logger.remove()
        logger.configure()
        logger.add(sink=sys.stderr, level="TRACE", colorize=True)
        logger.opt(colors=True)
        logger.error(f"""Debug level set to {config["debug"]}""")
        a = "| .... . .-.. .-.. ---/../.- --/.-/-.-. .... .. .-.. -../..-. .-. --- --/--- ..- -/... .--. .- -.-. ./.- -. -../../.-.. .. -.- ./-.-. -.-- -... . .-./.- -. -../-.-. .- -"
        result = ep.decrypt(a)
        logger.debug(result)
        logger.debug(result)
        self.assertEqual(result["IsPlaintext?"], True)
github Delgan / loguru / tests / test_patch.py View on Github external
def test_add_using_patched(writer):
    logger.configure(patcher=lambda r: r["extra"].update(a=-1))
    logger_patched = logger.patch(lambda r: r["extra"].update(a=0))
    logger_patched.add(writer, format="{extra[a]} {message}")
    logger.debug("A")
    logger_patched.debug("B")

    assert writer.read() == "-1 A\n0 B\n"
github Delgan / loguru / tests / test_bind.py View on Github external
def test_override_configured(writer):
    logger.configure(extra={"a": 1})
    logger2 = logger.bind(a=2)

    logger2.add(writer, format="{extra[a]} {message}")

    logger2.debug("?")

    assert writer.read() == "2 ?\n"
github Delgan / loguru / tests / test_contextualize.py View on Github external
def test_contextualize_after_configure(writer):
    logger.add(writer, format="{message} {extra[foobar]}")

    with logger.contextualize(foobar="baz"):
        logger.configure(extra={"foobar": "baz_2"})
        logger.info("A")

    logger.info("B")

    assert writer.read() == "A baz\nB baz_2\n"
github Map-A-Droid / MAD / utils / logging.py View on Github external
"diagnose": log_file_trace,
            "enqueue": True,
            "encoding": "UTF-8"
        }

        if args.log_file_retention != 0:
            log_file_retention = str(args.log_file_retention) + " days"
            file_logs["retention"] = log_file_retention

        if str(args.log_file_rotation) != "0":
            file_logs["rotation"] = str(args.log_file_rotation)

        logconfig["handlers"].append(file_logs)

    try:
        logger.configure(**logconfig)
    except ValueError:
        logger.error("Logging parameters/configuration is invalid.")
        sys.exit(1)

    logger.info("Setting log level to {} ({}).", str(log_level), log_level_label)
github FuelRats / pipsqueak3 / src / config / _parser.py View on Github external
loglevel = "INFO"

    # check for nocolor flag
    if args.nocolors:
        log_colors = False
    else:
        log_colors = True

    # check for new-log flag, overwriting existing log,
    # otherwise, append to the file per normal.
    if args.clean_log:
        log_filemode = 'w'
    else:
        log_filemode = 'a'

    logger.configure(
        handlers=[
            dict(sink=sys.stdout, format="<b>&lt;{time}</b> [{name}] "
                                         "{level.name} &gt; {message}",
                 colorize=True, backtrace=False, diagnose=False, level=loglevel),
            dict(sink=logfile, level="DEBUG", format="&lt; {time} &gt; "
                                                     "[ {module} ] {message}", rotation="50 MB",
                 enqueue=True, mode=log_filemode),
        ]
    )

    logger.info("Configuration file loading...")
github checktheroads / hyperglass / hyperglass / log.py View on Github external
def base_logger():
    """Initialize hyperglass logging instance."""
    _loguru_logger.remove()
    _loguru_logger.add(sys.stdout, format=_LOG_FMT, level="INFO", enqueue=True)
    _loguru_logger.configure(levels=_LOG_LEVELS)
    return _loguru_logger
github l3uddz / drive_strm / drive_strm.py View on Github external
# Load logger
    log_levels = {0: 'INFO', 1: 'DEBUG', 2: 'TRACE'}
    log_level = log_levels[verbose] if verbose in log_levels else 'TRACE'
    config_logger = {
        'handlers': [
            {'sink': sys.stdout, 'backtrace': True if verbose >= 2 else False, 'level': log_level},
            {'sink': log_path,
             'rotation': '30 days',
             'retention': '7 days',
             'enqueue': True,
             'backtrace': True if verbose >= 2 else False,
             'level': log_level}
        ]
    }
    logger.configure(**config_logger)

    # Load database
    db.init_db(vault_path)
    create_all_tables()

    # Load google drive
    manager = GoogleDriveManager(client_id=cfg.google.client_id, client_secret=cfg.google.client_secret,
                                 allowed_teamdrives=cfg.google.teamdrives, cfg=cfg)

    poller = GooglePoller(manager, cfg)

    # Load strm
    from utils import strm as strm_module
    strm = strm_module

    # Display params