Files
Client-Billing-software/app/service/logger.py
2026-04-15 12:05:28 +05:30

17 lines
519 B
Python

import os
from flask import current_app
from datetime import datetime
def log_activity(user, action, details=""):
try:
log_file = os.path.join(current_app.root_path, "activity.log")
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open(log_file, "a") as f:
f.write(
f"Timestamp: {timestamp} | User: {user} | "
f"Action: {action} | Details: {details}\n"
)
except Exception as e:
print(f"Logging failed: {e}")