def set_log_info(): os.environ['GLOG_v'] = '1' os.environ['GLOG_logtostderr'] = '1' os.environ['logger_maxBytes'] = '5242880' os.environ['GLOG_log_dir'] = 'D:/' if os.name == "nt" else '/var/log/mindspore' os.environ['logger_backupCount'] = '10' print(logger.get_log_config())
def test_log_default(): _rm_env_config() from mindspore import log as logger configdict = logger.get_log_config() targetdict = {'GLOG_v': '2', 'GLOG_logtostderr': '1'} assert configdict == targetdict # Clean up _global_logger to avoid affecting for next usecase logger._global_logger = None
def test_log_getconfig(): _rm_env_config() os.environ['GLOG_v'] = '3' os.environ['GLOG_logtostderr'] = '0' os.environ['GLOG_log_dir'] = '/tmp/log/' os.environ['logger_maxBytes'] = '1000' os.environ['logger_backupCount'] = '10' from mindspore import log as logger logger.info("test log message info test ") configdict = logger.get_log_config() targetdict = {'GLOG_v': '3', 'GLOG_log_dir': '/tmp/log', 'GLOG_logtostderr': '0', 'logger_maxBytes': 1000, 'logger_backupCount': 10} assert configdict == targetdict # Clean up _global_logger to avoid affecting for next usecase logger._global_logger = None