ames: use +trace to print logs

This commit is contained in:
yosoyubik 2022-04-22 10:06:53 +02:00
parent e2f8e21529
commit 087f24e931
2 changed files with 22 additions and 30 deletions

View File

@ -1220,8 +1220,8 @@
?~ parsed=(parse-bone-wire wire) ?~ parsed=(parse-bone-wire wire)
:: no-op :: no-op
:: ::
=/ =tape "ames dropping malformed wire: {(spud wire)}" ~> %slog.0^leaf/"ames: dropping malformed wire: {(spud wire)}"
(emit duct %pass /malformed-wire %d %flog %text tape) event-core
?> ?=([@ her=ship *] u.parsed) ?> ?=([@ her=ship *] u.parsed)
=* her her.u.parsed =* her her.u.parsed
=/ =peer-state (got-peer-state her) =/ =peer-state (got-peer-state her)
@ -1233,20 +1233,19 @@
== ==
:: ignore events from an old rift :: ignore events from an old rift
:: ::
?. odd.veb event-core %- %^ trace odd.veb her
(log "ames dropping old rift wire: {(spud wire)}") |.("dropping old rift wire: {(spud wire)}")
event-core
=/ =bone =/ =bone
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed) ?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
=? event-core.peer-core &(odd.veb ?=([%old *] u.parsed)) =? peer-core ?=([%old *] u.parsed)
(log "ames parsing old wire format: {(spud wire)}") %- %^ trace odd.veb her
|.("parsing old wire: {(spud wire)}")
peer-core
?~ error ?~ error
(send-ack bone) (send-ack bone)
(send-nack bone u.error) (send-nack bone u.error)
:: ::
++ log
|= =tape
^+ event-core
(emit duct %pass /on-take-done-parse-wire %d %flog %text tape)
:: if processing succeded, send positive ack packet and exit :: if processing succeded, send positive ack packet and exit
:: ::
++ send-ack ++ send-ack
@ -1525,9 +1524,9 @@
++ on-take-boon ++ on-take-boon
|= [=wire payload=*] |= [=wire payload=*]
^+ event-core ^+ event-core
|^
?~ parsed=(parse-bone-wire wire) ?~ parsed=(parse-bone-wire wire)
(log "ames dropping malformed wire: {(spud wire)}") ~> %slog.0^leaf/"ames: dropping malformed wire: {(spud wire)}"
event-core
:: ::
?> ?=([@ her=ship *] u.parsed) ?> ?=([@ her=ship *] u.parsed)
=* her her.u.parsed =* her her.u.parsed
@ -1540,19 +1539,16 @@
== ==
:: ignore events from an old rift :: ignore events from an old rift
:: ::
?. odd.veb event-core %- %^ trace odd.veb her
(log "ames dropping old rift wire: {(spud wire)}") |.("dropping old rift wire: {(spud wire)}")
event-core
=/ =bone =/ =bone
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed) ?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
=? event-core.peer-core &(odd.veb ?=([%old *] u.parsed)) =? peer-core ?=([%old *] u.parsed)
(log "ames parsing old wire: {(spud wire)}") %- %^ trace odd.veb her
|.("parsing old wire: {(spud wire)}")
peer-core
abet:(on-memo:peer-core bone payload %boon) abet:(on-memo:peer-core bone payload %boon)
::
++ log
|= =tape
^+ event-core
(emit duct %pass /on-take-boon-parse-wire %d %flog %text tape)
--
:: +on-plea: handle request to send message :: +on-plea: handle request to send message
:: ::
++ on-plea ++ on-plea

View File

@ -341,9 +341,8 @@
=^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1)) =^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
=^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~) =^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
%+ expect-eq %+ expect-eq
!> :^ ~[//unix] %pass /on-take-done-parse-wire !> 1
[%d %flog %text "ames parsing old wire format: /bone/~nec/1"] !> (lent `(list move:ames)`moves3)
!> (snag 0 `(list move:ames)`moves3)
:: ::
++ test-dangling-bone ^- tang ++ test-dangling-bone ^- tang
=^ moves0 bud (call bud ~[/g/hood] %spew [%odd]~) =^ moves0 bud (call bud ~[/g/hood] %spew [%odd]~)
@ -359,15 +358,12 @@
^- sign:ames ^- sign:ames
[%jael %public-keys %diff who=~nec %rift from=0 to=1] [%jael %public-keys %diff who=~nec %rift from=0 to=1]
:: %gall has a pending wire with the old rift, so sending a gift to :: %gall has a pending wire with the old rift, so sending a gift to
:: %ames on it will drop that request, and print a message to the user :: %ames on it will drop that request, not producing any moves
:: ::
=^ moves3 bud (take bud /bone/~nec/0/1 ~[//unix] %g %done ~) =^ moves3 bud (take bud /bone/~nec/0/1 ~[//unix] %g %done ~)
:: ::
%+ expect-eq %+ expect-eq
!> %- sy !> ~
:_ ~
:^ ~[//unix] %pass /on-take-done-parse-wire
[%d %flog %text "ames dropping old rift wire: /bone/~nec/0/1"]
!> (sy ,.moves3) !> (sy ,.moves3)
:: ::
++ test-ames-flow-with-new-rift ^- tang ++ test-ames-flow-with-new-rift ^- tang