-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
34 lines (31 loc) · 938 Bytes
/
utils.py
File metadata and controls
34 lines (31 loc) · 938 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
32
33
34
import getpass
import os
import platform
from datetime import datetime
import logging
def log_action(action, ticket_id, bug_id=None):
timestamp = datetime.utcnow().isoformat()
if bug_id:
print(f"[{timestamp}] {action}: SysAid Ticket ID {ticket_id} -> ADO Bug ID {bug_id}")
else:
print(f"[{timestamp}] {action}: SysAid Ticket ID {ticket_id}")
def get_current_user_identity():
"""
Identify the current OS user or service principal running the script.
Used for auditing purposes.
"""
try:
username = getpass.getuser()
hostname = platform.node()
return f"{username}@{hostname}"
except Exception as e:
return "unknown_user"
def setup_logger(log_file):
"""
Configure and return a logger instance.
"""
logging.basicConfig(
filename=log_file,
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s"
)