Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logger drag sensitive #1972

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ def save_user_datas(self):
config = Config()


def drag_sensitive(config):
if isinstance(config, str):
conf_dict: dict = json.loads(config)
for key in conf_dict:
if "key" in key or "secret" in key:
conf_dict[key] = conf_dict[key][0:3] + "*" * 5 + conf_dict[key][-3:]
return json.dumps(conf_dict, indent=4)
elif isinstance(config, dict):
for key in config:
if "key" in key or "secret" in key:
config[key] = config[key][0:3] + "*" * 5 + config[key][-3:]
return config

return config


def load_config():
global config
config_path = "./config.json"
Expand All @@ -232,7 +248,7 @@ def load_config():
config_path = "./config-template.json"

config_str = read_file(config_path)
logger.debug("[INIT] config str: {}".format(config_str))
logger.debug("[INIT] config str: {}".format(drag_sensitive(config_str)))

# 将json字符串反序列化为dict类型
config = Config(json.loads(config_str))
Expand All @@ -257,7 +273,7 @@ def load_config():
logger.setLevel(logging.DEBUG)
logger.debug("[INIT] set log level to DEBUG")

logger.info("[INIT] load config: {}".format(config))
logger.info("[INIT] load config: {}".format(drag_sensitive(config)))

config.load_user_datas()

Expand Down