Fix: fix load_yaml logging, Avoid setting the log level to warning (#5019)
Co-authored-by: huangyusong <huangyusong@yingzi.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import os
|
|||||||
import yaml
|
import yaml
|
||||||
from yaml import YAMLError
|
from yaml import YAMLError
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def load_yaml_file(file_path: str, ignore_error: bool = False) -> dict:
|
def load_yaml_file(file_path: str, ignore_error: bool = False) -> dict:
|
||||||
"""
|
"""
|
||||||
@@ -24,11 +25,11 @@ def load_yaml_file(file_path: str, ignore_error: bool = False) -> dict:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise YAMLError(f'Failed to load YAML file {file_path}: {e}')
|
raise YAMLError(f'Failed to load YAML file {file_path}: {e}')
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logging.debug(f'Failed to load YAML file {file_path}: {e}')
|
logger.debug(f'Failed to load YAML file {file_path}: {e}')
|
||||||
return {}
|
return {}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if ignore_error:
|
if ignore_error:
|
||||||
logging.warning(f'Failed to load YAML file {file_path}: {e}')
|
logger.warning(f'Failed to load YAML file {file_path}: {e}')
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
Reference in New Issue
Block a user