- Input: A string containing log entries
- Output: A dictionary containing:
total_errors
: Count of all error occurrencesunique_error_messages
: List of unique error messages
The implementation will utilize regular expressions to parse log entries and extract error messages with the following approach:
- Parse log entries to identify ERROR level messages
- Count total ERROR occurrences
- Collect and alphabetically sort unique error messages
- Handle edge cases and malformed inputs
The main function process_log_file
will be implemented with these considerations:
- Regular expression pattern matching for ERROR entries
- Message extraction and counting logic
- Comprehensive error handling for:
- Empty input validation
- Malformed input detection
- Input type verification
- Type hints for improved code clarity
Develop unit tests to verify:
- Basic functionality with valid inputs
- Edge case handling
- Error handling for invalid inputs
- Sorting and uniqueness requirements
- Runtime: Python 3.9+
- Memory Allocation: 128 MB
- Timeout Setting: 30 seconds
- IAM Role: Basic Lambda execution role
- Includes CloudWatch logging permissions
def lambda_handler(event, context):
# Implementation details here
pass