feat: upgrade logger - #1265
Merged
Merged
Conversation
tckeong
requested review from
RichDom2185 and
Copilot
and removed request for
Copilot
June 20, 2025 10:05
RichDom2185
force-pushed
the
feat/upgrade-logger
branch
from
August 5, 2025 21:37
8cdbc5a to
b124133
Compare
… feat/upgrade-logger
RichDom2185
approved these changes
Aug 14, 2025
RichDom2185
left a comment
Member
There was a problem hiding this comment.
LGTM, thank you so much! Really sorry for the delay in reviewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR upgrade the original logger, add a new logger backend (logger driver). The new logger backend, CloudWatch Logger, enabling buffered delivery of your application logs to AWS CloudWatch using
ExAws.How It Works
Initialization
On startup, this backend reads configuration options (
:log_group,:log_stream,:level,:format,:metadata) to set up its internal state.Buffering Logs
When the application emits a log, the
handle_event/2callback formats it, attaches metadata, timestamps it, and buffers it.Flush Trigger
Logs are flushed in two cases:
@max_buffer_size(immediately triggers async flush).@flush_interval) sends a:flush_buffermessage, flushing any pending logs.AWS Auth Check
Before sending, the logger verifies that AWS credentials and region are configured via environment variables. If missing, the flush is skipped (avoiding endless retry loops).
Retry Logic
Logs are sent using
ExAws.request/1, in%ExAws.Operation.JSON{}format. On failure, it retries up to@max_retries, with a delay of@retry_delaybetween attempts. An error is logged on each failure.Configuration Options
Add to your
config/*.exs:This PR integrates with Elixir’s Logger (:gen_event), offering buffered, retry-enabled delivery to AWS CloudWatch.