import os
import logging
from notion_client import Client
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

def get_page_blocks(page_id: str):
    """
    Fetch all blocks from a Notion page and print them to the console.
    
    Args:
        page_id: The ID of the Notion page to fetch
    """
    token = os.getenv('NOTION_TOKEN')
    if not token:
        raise ValueError("Notion token not provided and NOTION_TOKEN environment variable not set")
    
    notion = Client(auth=token)
    
    try:
        blocks = notion.blocks.children.list(block_id=page_id)
        print(blocks)
    except Exception as e:
        logger.error(f"Error retrieving page blocks: {str(e)}")
        raise

if __name__ == '__main__':
    page_id = "2725bd136a8480a69301d6e70171cdad"
    get_page_blocks(page_id)
