fix "datetime is not JSON serializable" err in debug log code

This commit is contained in:
forest 2021-01-29 00:19:05 -06:00
parent 274c7a2c76
commit 7914a2e518

View File

@ -1,6 +1,5 @@
import re import re
import sys import sys
import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from flask import Blueprint from flask import Blueprint
from flask import flash from flask import flash
@ -129,8 +128,9 @@ def create():
capacity_avaliable = current_app.config["VIRTUALIZATION_MODEL"].capacity_avaliable(512*1024*1024) capacity_avaliable = current_app.config["VIRTUALIZATION_MODEL"].capacity_avaliable(512*1024*1024)
errors = list() errors = list()
ssh_keys_from_db_string = "\n".join(list(map(lambda x: f"name: {x.name}**content: {x.content}", ssh_public_keys)))
email_to_log = session["account"] email_to_log = session["account"]
current_app.logger.info(f"create for {email_to_log}: ssh keys from db:\n {json.dumps(ssh_public_keys)}") current_app.logger.info(f"create for {email_to_log}: ssh keys from db:\n {ssh_keys_from_db_string}")
if request.method == "POST": if request.method == "POST":
if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']: if "csrf-token" not in request.form or request.form['csrf-token'] != session['csrf-token']:
@ -180,7 +180,8 @@ def create():
host(s) at capacity. no capsuls can be created at this time. sorry. host(s) at capacity. no capsuls can be created at this time. sorry.
""") """)
current_app.logger.info(f"create for {email_to_log}: posted_keys:\n {json.dumps(posted_keys)}") posted_keys_string = "\n".join(list(map(lambda x: f"name: {x.name}**content: {x.content}", posted_keys)))
current_app.logger.info(f"create for {email_to_log}: posted_keys:\n {posted_keys_string}")
if len(errors) == 0: if len(errors) == 0:
id = makeCapsulId() id = makeCapsulId()