示例#1
0
文件: logger.py 项目: jzuhone/yt
def _runtime_configuration(ytcfg: YTConfig) -> None:
    # only run this at the end of yt.__init__, after yt.config.ytcfg was instanciated

    global _original_emitter, _yt_sh

    if ytcfg.get("yt", "stdout_stream_logging"):
        stream = sys.stdout
    else:
        stream = sys.stderr

    _level = min(max(ytcfg.get("yt", "log_level"), 0), 50)

    if ytcfg.get("yt", "suppress_stream_logging"):
        disable_stream_logging()
    else:
        _yt_sh = logging.StreamHandler(stream=stream)
        # create formatter and add it to the handlers
        formatter = logging.Formatter(ufstring)
        _yt_sh.setFormatter(formatter)
        # add the handler to the logger
        ytLogger.addHandler(_yt_sh)
        ytLogger.setLevel(_level)
        ytLogger.propagate = False

        _original_emitter = _yt_sh.emit

        if ytcfg.get("yt", "colored_logs"):
            colorize_logging()
示例#2
0
def _setup_ramses_particle_families(ytcfg: YTConfig) -> None:
    if not ytcfg.has_section("ramses-families"):
        return
    for key in particle_families.keys():
        val = ytcfg.get("ramses-families", key, callback=None)
        if val is not None:
            mylog.info("Changing family %s from %s to %s", key,
                       particle_families[key], val)
            particle_families[key] = val