Skip to content

Commit 630042c

Browse files
committed
DynamoStore: Polish logging
1 parent f176499 commit 630042c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Equinox.DynamoStore/DynamoStore.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,10 @@ module internal Sync =
593593
|> Log.prop "eventTypes" (Seq.truncate 5 (seq { for x in appended -> x.c }))
594594
let appendedBytes, unfoldsBytes = Event.arrayBytes appended, Unfold.arrayBytes unfolds
595595
if calfBytes <> 0 then
596-
log.Information("EqxDynamo {action:l}{act:l} {outcome:l} {stream:l} {exp:l} {ms:f1}ms {ru}RU {appendedE}e {appendedB}b Tip {baseE}->{tipE}e {baseB}->{tipB}b Unfolds {unfolds} {unfoldsBytes}b Calf {calfEvents} {calfBytes}b",
597-
"Sync", "Calve", outcome, stream, exp, t.ElapsedMilliseconds, ru, appended.Length, appendedBytes, baseEvents, tipEvents, baseBytes, tipBytes, unfolds.Length, unfoldsBytes, calfCount, calfBytes)
598-
else log.Information("EqxDynamo {action:l}{act:l} {outcome:l} {stream:l} {exp:l} {ms:f1}ms {ru}RU {appendedE}e {appendedB}b Events {events} {tipB}b Unfolds {unfolds} {unfoldsB}b",
599-
"Sync", "Append", outcome, stream, exp, t.ElapsedMilliseconds, ru, appended.Length, appendedBytes, tipEvents, tipBytes, unfolds.Length, unfoldsBytes)
596+
log.Information("EqxDynamo {action:l}{act:l} {outcome:l} {stream:l} {ms:f1}ms {ru}RU {exp:l} {appendedE}e {appendedB}b Tip {baseE}->{tipE}e {baseB}->{tipB}b Unfolds {unfolds} {unfoldsBytes}b Calf {calfEvents} {calfBytes}b",
597+
"Sync", "Calve", outcome, stream, t.ElapsedMilliseconds, ru, exp, appended.Length, appendedBytes, baseEvents, tipEvents, baseBytes, tipBytes, unfolds.Length, unfoldsBytes, calfCount, calfBytes)
598+
else log.Information("EqxDynamo {action:l}{act:l} {outcome:l} {stream:l} {ms:f1}ms {ru}RU {exp:l} {appendedE}e {appendedB}b Events {events} {tipB}b Unfolds {unfolds} {unfoldsB}b",
599+
"Sync", "Append", outcome, stream, t.ElapsedMilliseconds, ru, exp, appended.Length, appendedBytes, tipEvents, tipBytes, unfolds.Length, unfoldsBytes)
600600
return result }
601601

602602
[<RequireQualifiedAccess; NoEquality; NoComparison>]
@@ -659,9 +659,8 @@ module internal Tip =
659659
let eventsCount, unfoldsCount, bb, ub = tip.e.Length, tip.u.Length, Batch.bytesBase tip, Batch.bytesUnfolds tip
660660
let log = logMetric (bb + ub) (eventsCount + unfoldsCount) Log.Metric.Tip
661661
let log = match maybePos with Some p -> log |> Log.prop "startPos" p |> Log.prop "startEtag" p | None -> log
662-
let log = log |> Log.prop "etag" tip.etag //|> Log.prop "n" tip.n
663-
log.Information("EqxDynamo {action:l} {res} {stream:l} v{n} {ms:f1}ms {ru}RU {events}e {unfolds}u {baseBytes}+{unfoldsBytes}b",
664-
"Tip", 200, stream, tip.n, t.ElapsedMilliseconds, ru, eventsCount, unfoldsCount, bb, ub)
662+
log.Information("EqxDynamo {action:l} {res} {stream:l} v{n} {ms:f1}ms {ru}RU {etag} {events}e {unfolds}u {baseBytes}+{unfoldsBytes}b",
663+
"Tip", 200, stream, tip.n, t.ElapsedMilliseconds, ru, tip.etag, eventsCount, unfoldsCount, bb, ub)
665664
return ru, res }
666665
let private enumEventsAndUnfolds (minIndex, maxIndex) (x : Batch) : ITimelineEvent<InternalBody> array =
667666
Seq.append<ITimelineEvent<_>> (Batch.enumEvents (minIndex, maxIndex) x |> Seq.cast) (x.u |> Seq.cast)
@@ -760,12 +759,13 @@ module internal Query =
760759
|> AsyncSeq.takeWhileInclusive (function
761760
| struct (x, ValueSome e) when isOrigin e ->
762761
found <- true
762+
let logLevel = if x.i = 0 then Events.LogEventLevel.Debug else Events.LogEventLevel.Information
763763
match lastResponse with
764-
| None -> log.Information("EqxDynamo Stop stream={stream} at={index} {case}", stream, x.i, x.c)
764+
| None -> log.ForContext("stream", stream).Write(logLevel, "EqxDynamo Stop @{index} {case}", x.i, x.c)
765765
| Some batch ->
766766
let used, residual = batch |> calculateUsedVersusDroppedPayload x.i
767-
log.Information("EqxDynamo Stop stream={stream} at={index} {case} used={used} residual={residual}",
768-
stream, x.i, x.c, used, residual)
767+
log.ForContext("stream", stream)
768+
.Write(logLevel, "EqxDynamo Stop @{index} {case} used {used}b residual {residual}b", x.i, x.c, used, residual)
769769
false
770770
| _ -> true)
771771
|> AsyncSeq.toArrayAsync

0 commit comments

Comments
 (0)