-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
31 lines (23 loc) · 686 Bytes
/
Copy pathlogger.py
File metadata and controls
31 lines (23 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# logger.py
import os
import json
import logging
from datetime import datetime
log = logging.getLogger("iam_orchestrator")
if not log.handlers:
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
LOG_DIR = "logs"
LOG_FILE = os.path.join(LOG_DIR, "iam_audit.log")
# Ensure log directory exists
os.makedirs(LOG_DIR, exist_ok=True)
def log_event(action: str, details: dict):
"""
Write a structured audit log entry.
"""
entry = {
"timestamp": datetime.utcnow().isoformat() + "Z",
"action": action,
"details": details
}
with open(LOG_FILE, "a") as f:
f.write(json.dumps(entry) + "\n")