logWrite replaced with logging module
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from os import makedirs, path, remove, system
|
||||
@@ -43,14 +44,18 @@ from modules.security import (
|
||||
get_current_active_user,
|
||||
get_user,
|
||||
)
|
||||
from modules.utils import configGet, logWrite
|
||||
from modules.utils import configGet
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def compress_image(image_path: str):
|
||||
image_type = Magic(mime=True).from_file(image_path)
|
||||
|
||||
if image_type not in ["image/jpeg", "image/png"]:
|
||||
logWrite(f"Not compressing {image_path} because its mime is '{image_type}'")
|
||||
logger.info(
|
||||
"Not compressing %s because its mime is '%s'", image_path, image_type
|
||||
)
|
||||
return
|
||||
|
||||
size_before = path.getsize(image_path) / 1024
|
||||
@@ -66,12 +71,15 @@ async def compress_image(image_path: str):
|
||||
return
|
||||
|
||||
task.start()
|
||||
logWrite(f"Compressing '{Path(image_path).name}'...")
|
||||
logger.info("Compressing '%s'...", Path(image_path).name)
|
||||
task.join()
|
||||
|
||||
size_after = path.getsize(image_path) / 1024
|
||||
logWrite(
|
||||
f"Compressed '{Path(image_path).name}' from {size_before} Kb to {size_after} Kb"
|
||||
logger.info(
|
||||
"Compressed '%s' from %s Kb to %s Kb",
|
||||
Path(image_path).name,
|
||||
size_before,
|
||||
size_after,
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from uuid import uuid1
|
||||
|
||||
@@ -21,7 +22,9 @@ from modules.security import (
|
||||
get_user,
|
||||
verify_password,
|
||||
)
|
||||
from modules.utils import configGet, logWrite
|
||||
from modules.utils import configGet
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def send_confirmation(user: str, email: str):
|
||||
@@ -41,9 +44,11 @@ async def send_confirmation(user: str, email: str):
|
||||
col_emails.insert_one(
|
||||
{"user": user, "email": email, "used": False, "code": confirmation_code}
|
||||
)
|
||||
logWrite(f"Sent confirmation email to '{email}' with code {confirmation_code}")
|
||||
logger.info(
|
||||
"Sent confirmation email to '%s' with code %s", email, confirmation_code
|
||||
)
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not send confirmation email to '{email}' due to: {exp}")
|
||||
logger.error("Could not send confirmation email to '%s' due to: %s", email, exp)
|
||||
|
||||
|
||||
@app.get("/users/me/", response_model=User)
|
||||
|
Reference in New Issue
Block a user