Skip to content

Commit

Permalink
logging updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Mole1424 committed Aug 21, 2023
1 parent 0486407 commit 24adcfd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps
from logging import log, warning
from logging import INFO, basicConfig, info, warning
from os import environ, getenv

from flask import Flask, redirect, render_template, request, session
Expand Down Expand Up @@ -49,6 +49,8 @@ def wrapper(*args, **kwargs):
storage_uri="memory://",
)

basicConfig(level=INFO) # allows info to be displayed in portainer logs


@app.route("/")
@app.route("/home")
Expand Down Expand Up @@ -227,7 +229,7 @@ def delete_project(project_id: int):

def log_blog_change(ip: str, action: str, project_id: int, success: bool):
# higher order functions++
log_func = log if success else warning
log_func = info if success else warning
log_func(
f"{ip} {action} blog for project {project_id} {'' if success else 'un'}successfully"
)
Expand All @@ -251,7 +253,7 @@ def login():
def logging_in():
if check_password_hash(password, request.form["password"]):
session["logged_in"] = True
log(f"{request.remote_addr} logged in")
info(f"{request.remote_addr} logged in")
return redirect("/")
else:
warning(
Expand Down

0 comments on commit 24adcfd

Please sign in to comment.