Skip to content

Add support for JSON Structured Logging#638

Open
sebsto wants to merge 28 commits intomainfrom
feature/structured-json-logging
Open

Add support for JSON Structured Logging#638
sebsto wants to merge 28 commits intomainfrom
feature/structured-json-logging

Conversation

@sebsto
Copy link
Collaborator

@sebsto sebsto commented Feb 12, 2026

This PR adds support for Structured Logging, as per the design document

@sebsto sebsto self-assigned this Feb 12, 2026
@sebsto sebsto added the 🆕 semver/minor Adds new public API. label Feb 12, 2026
@sebsto sebsto marked this pull request as draft February 12, 2026 14:39
@sebsto sebsto linked an issue Feb 12, 2026 that may be closed by this pull request
33 tasks
@sebsto sebsto changed the title WIP add support for JSON Structured Logging Add support for JSON Structured Logging Feb 12, 2026
@sebsto sebsto requested a review from Copilot February 13, 2026 07:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements JSON structured logging support for AWS Lambda functions, aligning with AWS Lambda's advanced logging controls. The implementation adds the ability to emit logs in JSON format when AWS_LAMBDA_LOG_FORMAT=JSON is set, while maintaining full backward compatibility with existing text-based logging.

Changes:

  • Introduces LoggingConfiguration to handle environment variable parsing and logger factory logic with proper precedence rules for AWS_LAMBDA_LOG_LEVEL vs LOG_LEVEL
  • Adds JSONLogHandler to format logs as JSON with Lambda-specific metadata (requestId, traceId)
  • Updates LambdaRuntime and LambdaManagedRuntime to use the new logging configuration and create per-request loggers
  • Provides comprehensive JSONLogging example with deployment templates and documentation
  • Updates design proposal and other documentation

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
Sources/AWSLambdaRuntime/Logging/LoggingConfiguration.swift New file implementing logging configuration with environment variable parsing and logger factory methods
Sources/AWSLambdaRuntime/Logging/JSONLogHandler.swift New file implementing JSON log handler with structured output to stderr
Sources/AWSLambdaRuntime/Runtime/LambdaRuntime.swift Updated to initialize and use LoggingConfiguration, create per-request loggers
Sources/AWSLambdaRuntime/ManagedRuntime/LambdaManagedRuntime.swift Updated to initialize and use LoggingConfiguration, create per-request loggers
Sources/AWSLambdaRuntime/Lambda.swift Updated runLoop to create per-request loggers, deprecated old runLoop signature
Tests/AWSLambdaRuntimeTests/LambdaRunLoopTests.swift Updated tests to use new runLoop signature with LoggingConfiguration
Sources/AWSLambdaRuntime/Docs.docc/Proposals/0002-logging.md New design document describing the structured logging feature
Sources/AWSLambdaRuntime/Docs.docc/managed-instances.md Header level adjustments for consistency
Sources/AWSLambdaRuntime/Docs.docc/Deployment.md Header level adjustment for consistency
Examples/JSONLogging/* Complete example demonstrating JSON logging with SAM templates and README

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sebsto sebsto marked this pull request as ready for review February 14, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🆕 semver/minor Adds new public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[core] Add Support for Structured JSON Logging

1 participant