Skip to content

Commit

Permalink
Merge pull request #47 from invenia/tl/memento13
Browse files Browse the repository at this point in the history
Support Memento>=1.3
  • Loading branch information
timmylev authored Jan 10, 2023
2 parents 12e8bd9 + aa4d7e2 commit a6dbce2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "CloudWatchLogs"
uuid = "c4c1e6a2-6bdd-52e0-b56d-1d4734724d2d"
version = "2.0.0"
version = "2.1.0"

[deps]
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
Expand All @@ -14,7 +14,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
[compat]
AWS = "1"
MbedTLS = "1"
Memento = "~1.0, ~1.1, ~1.2"
Memento = "1"
Mocking = "0.7"
TimeZones = "1"
julia = "1.3" # Minimum version for MbedTLS@1
Expand Down
3 changes: 3 additions & 0 deletions src/handler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ end

function Memento.emit(handler::CloudWatchLogHandler, record::Record)
dt = isdefined(record, :date) ? record.date : Dates.now(tz"UTC")
# Memento@1.3 switched to only storing DateTime in order to make TimeZones.jl an
# optional dependency, but AWS requries timestamps in UTC, so we need a ZDT
dt = isa(dt, DateTime) ? astimezone(ZonedDateTime(dt, localzone()), tz"UTC") : dt
message = format(handler.fmt, record)
event = LogEvent(message, dt)
return put!(handler.channel, event)
Expand Down
32 changes: 17 additions & 15 deletions test/online.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,23 @@
@test_throws LOGGER LogSubmissionException submit_logs(stream, events)
end

@testset "Invalid sequence token" begin
stream = CloudWatchLogStream(
CFG,
TEST_LOG_GROUP,
create_stream(CFG, TEST_LOG_GROUP, new_stream("invalid_token")),
)

@test submit_log(stream, LogEvent("Foo")) == 1
CloudWatchLogs.update_sequence_token!(stream, "oops_invalid")
setlevel!(LOGGER, "debug") do
@test_log LOGGER "debug" "InvalidSequenceTokenException" begin
submit_log(stream, LogEvent("Second time's the charm"))
end
end
end
# InvalidSequenceToken errors are no longer a thing:
# - https://github.com/invenia/CloudWatchLogs.jl/issues/45
# @testset "Invalid sequence token" begin
# stream = CloudWatchLogStream(
# CFG,
# TEST_LOG_GROUP,
# create_stream(CFG, TEST_LOG_GROUP, new_stream("invalid_token")),
# )

# @test submit_log(stream, LogEvent("Foo")) == 1
# CloudWatchLogs.update_sequence_token!(stream, "oops_invalid")
# setlevel!(LOGGER, "debug") do
# @test_log LOGGER "debug" "InvalidSequenceTokenException" begin
# submit_log(stream, LogEvent("Second time's the charm"))
# end
# end
# end

@testset "Unsorted logs" begin
stream_name = new_stream("unsorted")
Expand Down

2 comments on commit a6dbce2

@timmylev
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/75468

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.1.0 -m "<description of version>" a6dbce2a52688c65ac8aa0f57978b9989654af9b
git push origin v2.1.0

Please sign in to comment.