Skip to content

Commit

Permalink
Fix: fix load_yaml logging, Avoid setting the log level to warning (l…
Browse files Browse the repository at this point in the history
…anggenius#5019)

Co-authored-by: huangyusong <huangyusong@yingzi.com>
  • Loading branch information
fishisnow and huangyusongyz authored Jun 12, 2024
1 parent b399e8a commit 11fd4a5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/core/tools/utils/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import yaml
from yaml import YAMLError

logger = logging.getLogger(__name__)

def load_yaml_file(file_path: str, ignore_error: bool = False) -> dict:
"""
Expand All @@ -24,11 +25,11 @@ def load_yaml_file(file_path: str, ignore_error: bool = False) -> dict:
except Exception as e:
raise YAMLError(f'Failed to load YAML file {file_path}: {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 {}
except Exception as e:
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 {}
else:
raise e

0 comments on commit 11fd4a5

Please sign in to comment.