From 7aad83c12a29050447949de573af445e1e3456d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 3 Jan 2025 21:16:08 +0800 Subject: [PATCH 1/4] logs: add to /lib and /sur --- desk/lib/logs.hoon | 73 ++++++++++++++++++++++++++++++++++++++++++++++ desk/sur/logs.hoon | 24 +++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 desk/lib/logs.hoon create mode 100644 desk/sur/logs.hoon diff --git a/desk/lib/logs.hoon b/desk/lib/logs.hoon new file mode 100644 index 0000000..db4576f --- /dev/null +++ b/desk/lib/logs.hoon @@ -0,0 +1,73 @@ +/- *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 + =- ?~ id.e - + [id/s+u.id.e -] + :~ type/s+event-type + message/(tang echo.e) + volume/s+vol.e + == + == + -- +-- diff --git a/desk/sur/logs.hoon b/desk/sur/logs.hoon new file mode 100644 index 0000000..ba70701 --- /dev/null +++ b/desk/sur/logs.hoon @@ -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: an event with timestamp ++$ log-item [=time event=log-event] +:: ++$ a-log + $% [%log log-event] + == +-- From 9cf4e7ce345e32097ef321b5358d63707de7b3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 3 Jan 2025 21:16:28 +0800 Subject: [PATCH 2/4] bait & reel: lure logs --- desk/app/bait.hoon | 27 +++++++++++++++++---------- desk/app/reel.hoon | 17 ++++++++++++----- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/desk/app/bait.hoon b/desk/app/bait.hoon index 08f7ae7..bd2e91c 100644 --- a/desk/app/bait.hoon +++ b/desk/app/bait.hoon @@ -1,5 +1,5 @@ /- reel -/+ default-agent, verb, dbug, server, *reel +/+ default-agent, verb, dbug, server, logs, *reel |% +$ card card:agent:gall +$ versioned-state @@ -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) @@ -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+"{} redeemed lure invite from {}"] + :: + :* %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) @@ -220,5 +223,9 @@ [~ this] == :: -++ on-fail on-fail:def +++ on-fail + |= [=term =tang] + ^- (quip card _this) + :_ this + [(fail:log term tang)]~ -- diff --git a/desk/app/reel.hoon b/desk/app/reel.hoon index c9deba6..f13150d 100644 --- a/desk/app/reel.hoon +++ b/desk/app/reel.hoon @@ -1,5 +1,5 @@ /- reel -/+ default-agent, verb, dbug, *reel +/+ default-agent, verb, dbug, logs, *reel |% +$ card card:agent:gall +$ versioned-state @@ -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) @@ -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 @@ -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 @ @ ~] @@ -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)]~ -- From 7ec493952f4219f36f39ed2131e151343e1e2af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Fri, 3 Jan 2025 21:26:56 +0800 Subject: [PATCH 3/4] logs: minor fix --- desk/sur/logs.hoon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desk/sur/logs.hoon b/desk/sur/logs.hoon index ba70701..83ed045 100644 --- a/desk/sur/logs.hoon +++ b/desk/sur/logs.hoon @@ -15,7 +15,7 @@ [%tell id=(unit @ta) vol=volume =echo] == :: -:: $log-item: an event with timestamp +:: $log-item: event with timestamp +$ log-item [=time event=log-event] :: +$ a-log From 1c4a2654eec0e25b78ddf961e2070f6d6fa2160d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Paraniak?= Date: Sat, 4 Jan 2025 17:03:21 +0800 Subject: [PATCH 4/4] logs: add comment --- desk/lib/logs.hoon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desk/lib/logs.hoon b/desk/lib/logs.hoon index db4576f..b6896e4 100644 --- a/desk/lib/logs.hoon +++ b/desk/lib/logs.hoon @@ -62,6 +62,8 @@ %tell =- ?>(?=(%o -.-) -) %- pairs:enjs + :: + :: insert tell id if present =- ?~ id.e - [id/s+u.id.e -] :~ type/s+event-type