import os
from datetime import datetime

def make_memory_log_file():
    """
    Create memory log file path following project conventions.
    Returns the path to the CSV file for memory logging.
    """
    base_dir = '/var/www/html/status_management/src'
    folder_name = os.path.join(base_dir, 'file', 'memory_logs')
    timestamp = datetime.now().strftime('%Y-%m-%d')
    file_name = f'memory_usage_{timestamp}.csv'
    csv_file_path = os.path.join(folder_name, file_name)

    # Create directory if it doesn't exist
    if not os.path.exists(folder_name):
        os.makedirs(folder_name, exist_ok=True)
        
    # Create file with headers if it doesn't exist
    if not os.path.exists(csv_file_path):
        with open(csv_file_path, 'w', encoding='utf-8') as f:
            f.write('Timestamp,Stage,Memory_MB,User_Info\n')
            
    return csv_file_path
