Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Lure flow logging in %reel and %bait #303

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions desk/app/bait.hoon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/- reel
/+ default-agent, verb, dbug, server, *reel
/+ default-agent, verb, dbug, server, logs, *reel
|%
+$ card card:agent:gall
+$ versioned-state
Expand Down Expand Up @@ -64,8 +64,9 @@
%- agent:dbug
%+ verb |
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
::
++ on-init
^- (quip card _this)
Expand Down Expand Up @@ -115,22 +116,24 @@
::
%'POST'
?~ body.request
:- (tell:log ~ %crit 'body not found' ~)
(give-not-found 'body not found')
?. =('ship=%7E' (end [3 8] q.u.body.request))
:- (tell:log ~ %crit 'ship not found in body' ~)
(give-not-found 'ship not found in body')
=/ joiner (slav %p (cat 3 '~' (rsh [3 8] q.u.body.request)))
=; [=bite:reel inviter=(unit ship)]
?~ inviter
:- (tell:log `token.bite %crit 'inviter not found' ~)
(give-not-found 'inviter not found')
^- (list card)
:: TODO: figure out if we need to send both pokes
:* :* %pass /bite %agent [u.inviter %reel]
:* %^ tell:log `token.bite %info
~[leaf+"{<joiner>} redeemed lure invite from {<u.inviter>}"]
::
:* %pass /bite %agent [u.inviter %reel]
%poke %reel-bite !>(bite)
==
:* %pass /bite %agent [our.bowl %reel]
%poke %reel-bite !>(bite)
==
(give (manx-response:gen:server (sent-page joiner)))
(give (manx-response:gen:server (sent-page joiner)))
==
=/ =(pole knot) line
?: ?=([@ @ ~] line)
Expand Down Expand Up @@ -220,5 +223,9 @@
[~ this]
==
::
++ on-fail on-fail:def
++ on-fail
|= [=term =tang]
^- (quip card _this)
:_ this
[(fail:log term tang)]~
--
17 changes: 12 additions & 5 deletions desk/app/reel.hoon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/- reel
/+ default-agent, verb, dbug, *reel
/+ default-agent, verb, dbug, logs, *reel
|%
+$ card card:agent:gall
+$ versioned-state
Expand Down Expand Up @@ -66,8 +66,9 @@
%- agent:dbug
%+ verb |
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
+* this .
def ~(. (default-agent this %|) bowl)
log ~(. logs [our.bowl /logs])
::
++ on-init
^- (quip card _this)
Expand Down Expand Up @@ -174,6 +175,7 @@
:_ this
=/ url (cat 3 vic token)
=/ path (stab (cat 3 '/v1/id-link/' id))
:- (tell:log `token %info 'lure link generated' ~)
~[[%give %fact ~[path] %json !>(s+url)]]
::
%reel-undescribe
Expand Down Expand Up @@ -298,7 +300,8 @@
[%set-ship ~]
?> ?=([%khan %arow *] sign-arvo)
?: ?=(%.n -.p.sign-arvo)
((slog 'reel: fetch bait ship failed' p.p.sign-arvo) `this)
:_ this
~[(tell:log ~ %warn 'fetch bait ship failed' ~)]
`this
::
[%expire @ @ ~]
Expand All @@ -313,5 +316,9 @@
(on-arvo:def wire sign-arvo)
==
==
++ on-fail on-fail:def
++ on-fail
|= [=term =tang]
^- (quip card _this)
:_ this
[(fail:log term tang)]~
--
75 changes: 75 additions & 0 deletions desk/lib/logs.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/- *logs
=<
|_ [our=ship =wire]
::
++ fail
|= [desc=term trace=tang]
^- card:agent:gall
=/ event=$>(%fail log-event)
[%fail desc trace]
(pass event)
::
++ tell
|= [id=(unit @ta) vol=volume =echo]
^- card:agent:gall
=/ event=$>(%tell log-event)
[%tell id vol echo]
(pass event)
::
++ pass
|= event=log-event
^- card:agent:gall
[%pass wire %agent [our %logs] %poke log-action+!>([%log event])]
--
|%
::
++ fail-event
|= [=term =tang]
^- $>(%fail log-event)
[%fail term tang]
::
++ tell-event
|= [id=(unit @ta) vol=volume =echo]
^- $>(%tell log-event)
[%tell id vol echo]
::
++ enjs
=, format
|%
++ tang
|= t=^tang
^- $>(%a json)
?~ t a+~
=/ tame=(list tape)
%- zing
%+ turn t
(cury wash [0 80])
a+(turn tame tape:enjs)
::
++ log-event
|= e=^log-event
^- $>(%o json)
=* event-type -.e
?- -.e
%fail
=- ?>(?=(%o -.-) -)
%- pairs:enjs
:~ type/s+event-type
description/s+desc.e
stacktrace/(tang trace.e)
==
::
%tell
=- ?>(?=(%o -.-) -)
%- pairs:enjs
::
:: insert tell id if present
=- ?~ id.e -
[id/s+u.id.e -]
:~ type/s+event-type
message/(tang echo.e)
volume/s+vol.e
==
==
--
--
24 changes: 24 additions & 0 deletions desk/sur/logs.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/+ mp=mop-extensions
::
|%
:: $echo: formatted message
+$ echo (list tank)
:: $volume: echo volume
+$ volume ?(%info %warn %crit)
:: $log-event
::
:: %fail: agent failure
:: %tell: agent message
::
+$ log-event
$% [%fail desc=term trace=tang]
[%tell id=(unit @ta) vol=volume =echo]
==
::
:: $log-item: event with timestamp
+$ log-item [=time event=log-event]
::
+$ a-log
$% [%log log-event]
==
--
Loading