format_log(level, message, secrets) that builds a log line "[LEVEL] message", but first replaces every occurrence of any string in the list secrets within message with "***". level should be uppercased in the output regardless of how it was passed in.format_log("info", "user pass123 logged in", ["pass123"])'[INFO] user *** logged in'
The secret substring is redacted and level is uppercased.
format_log("error", "no secrets here", [])'[ERROR] no secrets here'
Empty secrets list leaves message untouched.
Loop over secrets and use message.replace(secret, "***") for each.
Uppercase level with level.upper() when building the final string.