mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-04 03:25:30 +08:00
Ref: update loggings (#11987)
### What problem does this PR solve? Ref: update loggins ### Type of change - [x] Refactoring
This commit is contained in:
@ -57,8 +57,18 @@ class MinerUOcrModel(Base, MinerUParser):
|
||||
self.mineru_server_url = _resolve_config("mineru_server_url", "MINERU_SERVER_URL", "")
|
||||
self.mineru_delete_output = bool(int(_resolve_config("mineru_delete_output", "MINERU_DELETE_OUTPUT", 1)))
|
||||
|
||||
# Redact sensitive config keys before logging
|
||||
redacted_config = {}
|
||||
for k, v in config.items():
|
||||
if any(
|
||||
sensitive_word in k.lower()
|
||||
for sensitive_word in ("key", "password", "token", "secret")
|
||||
):
|
||||
redacted_config[k] = "[REDACTED]"
|
||||
else:
|
||||
redacted_config[k] = v
|
||||
logging.info(
|
||||
f"Parsed MinerU config: backend={self.mineru_backend} api={self.mineru_api} server_url={self.mineru_server_url} output_dir={self.mineru_output_dir} delete_output={self.mineru_delete_output}"
|
||||
f"Parsed MinerU config (sensitive fields redacted): {redacted_config}"
|
||||
)
|
||||
|
||||
MinerUParser.__init__(self, mineru_api=self.mineru_api, mineru_server_url=self.mineru_server_url)
|
||||
|
||||
@ -41,10 +41,20 @@ def get_opendal_config():
|
||||
scheme = opendal_config.get("scheme")
|
||||
config_data = opendal_config.get("config", {})
|
||||
kwargs = {"scheme": scheme, **config_data}
|
||||
safe_log_keys=['scheme', 'host', 'port', 'database', 'table']
|
||||
|
||||
# Only include non-sensitive keys in logs. Do NOT
|
||||
# add 'password' or any key containing embedded credentials
|
||||
# (like 'connection_string').
|
||||
safe_log_keys = ['scheme', 'host', 'port', 'database', 'table']
|
||||
loggable_kwargs = {k: v for k, v in kwargs.items() if k in safe_log_keys}
|
||||
logging.info("Loaded OpenDAL configuration(non sensitive): %s", loggable_kwargs)
|
||||
return kwargs
|
||||
logging.info("Loaded OpenDAL configuration (non sensitive): %s", loggable_kwargs)
|
||||
|
||||
# For safety, explicitly remove sensitive keys from kwargs after use
|
||||
if "password" in kwargs:
|
||||
del kwargs["password"]
|
||||
if "connection_string" in kwargs:
|
||||
del kwargs["connection_string"]
|
||||
return kwargs
|
||||
except Exception as e:
|
||||
logging.error("Failed to load OpenDAL configuration from yaml: %s", str(e))
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user