-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Update request_logger.py #10009
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
Update request_logger.py #10009
Conversation
Saving api logs failed when Seedream4 official template was used on windows machine, due to the forbidden "=?:" characters in the filename, as well as the filename being too long. Regex keeps only usable characters, and 220 arbitrary max filename length is added.
|
@Kosinkadink initial problem is in that the logger attach all headers to the path: Maybe better to completely rewrite that to fix the root issue? |
| log_dir = get_log_directory() | ||
| timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S_%f") | ||
| filename = f"{timestamp}_{operation_id.replace('/', '_').replace(':', '_')}.log" | ||
| safe_operation_id = re.sub(r'[^A-Za-z0-9._-]', '_', operation_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to strip everything instead of just the illegal characters?
*/:\"<|>?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I am just a noob and this is the first idea I got that solved it for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, welcome, and thank you for the contribution. =)
|
Yeah, for this one I'd say strip it so that the headers are not part of the name, will be much cleaner. |
Fix for "Error writing API log to: ......"
Saving api logs failed when Seedream4 official template was used on windows machine, due to the forbidden "=?:" characters in the filename, as well as the filename being too long.
Regex keeps only usable characters, and 220 arbitrary max filename length is added.