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/2
callback 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_buffer
message, 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_delay
between 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.