⚠️ What This Script Actually Does:
This script demonstrates the enhanced logging system by generating both stdout (what you see on this page) and stderr (debug messages that only appear in CloudWatch Logs). The Lambda function captures ALL script output and sends it to CloudWatch with structured formatting and emoji markers.
🎯 Real-Time Logging Demonstration
What's happening right now:
- This script generated stderr debug messages during execution
- The Lambda function captured both stdout (this HTML) and stderr (debug info)
- All output was logged to CloudWatch with timestamps and emoji markers
- Performance metrics were recorded (execution time, file size, etc.)
📊 Live System Information
Current execution timestamp:
Sun Sep 7 17:49:47 UTC 2025
Hostname: Lambda container
Available tools: bash curl
Shell: /sbin/nologin
🔍 How to View the Actual Logs
To see what this script actually logged to CloudWatch:
1. Using AWS CLI (if you have access):
# View recent logs from the Lambda function
aws logs filter-log-events \
--log-group-name /aws/lambda/serverless-cgi-cgi-handler \
--start-time $(date -d '10 minutes ago' +%s)000 \
--filter-pattern "debug_test.sh"
# Or view all recent logs with structured output
aws logs filter-log-events \
--log-group-name /aws/lambda/serverless-cgi-cgi-handler \
--start-time $(date -d '5 minutes ago' +%s)000
2. Using AWS Console:
- Go to AWS Console → CloudWatch → Logs
- Find log group:
/aws/lambda/serverless-cgi-cgi-handler
- Look for recent log streams
- Search for "debug_test.sh" to find this execution
📝 Example of What You'll See in CloudWatch
The Lambda function logged something like this:
[INFO] 🚀 Processing GET /debug_test.sh
[INFO] 📁 Script setup:
📋 File: debug_test.sh (2856 bytes)
⬇️ Download: 0.045s
🔧 Interpreter: /bin/bash
📝 Preview: ['#!/bin/bash', '# Enhanced logging demonstration', '']
[INFO] ⚡ Script execution completed:
⏱️ Duration: 0.078s
🎯 Exit code: 0
📤 Stdout: 3420 chars
📤 Stderr: 486 chars
[INFO] 🐚 Shell debug output:
DEBUG: Script started at [timestamp]
DEBUG: Working directory: /tmp
DEBUG: Checking Lambda environment...
DEBUG: Lambda runtime detected
DEBUG: Scanning available system tools...
DEBUG: Found python3 at /var/lang/bin/python3.13
DEBUG: Found bash at /bin/bash
DEBUG: Found curl at /usr/bin/curl
DEBUG: System info displayed to user
DEBUG: Available commands: python3 bash curl
[INFO] 🎯 Request completed:
⏱️ Total time: 0.234s
📊 Status: 200
📦 Response size: 3420 chars
🚀 Enhanced Logging Features
What makes this logging system special:
- 📊 Structured Output: Multi-line blocks with emoji markers for easy scanning
- ⏱️ Performance Metrics: Execution timing, file sizes, response metrics
- 🔍 Complete Capture: Both stdout and stderr are fully logged
- 🎯 Request Correlation: Each request is tracked from start to finish
- 📁 Script Details: File size, download time, interpreter detection
- 🐚 Smart Error Handling: Shell stderr treated as debug info, not errors
💡 Pro Tip: Every time you load this page, new log entries are created in CloudWatch. You can use the AWS CLI commands above to see the real-time logging data, including all the "DEBUG:" messages that were sent to stderr during this script's execution.