From 51ca180a94b47d0a2d2b49b0ada74792e33d4050 Mon Sep 17 00:00:00 2001 From: Tenari Date: Thu, 13 Jul 2023 15:06:17 -0500 Subject: [PATCH] hide-logs unless you manually turn them on --- desks/realm/app/bedrock.hoon | 54 +++++++++++++++++++----------------- desks/realm/lib/db.hoon | 52 ++++++++++++++++++++-------------- desks/realm/sur/db.hoon | 3 ++ 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/desks/realm/app/bedrock.hoon b/desks/realm/app/bedrock.hoon index 882197a951..45b55869c0 100644 --- a/desks/realm/app/bedrock.hoon +++ b/desks/realm/app/bedrock.hoon @@ -96,6 +96,8 @@ %create-initial-spaces-paths (create-initial-spaces-paths:db state bowl) + %toggle-hide-logs + (toggle-hide-logs:db +.act state bowl) == [cards this] :: @@ -131,7 +133,7 @@ =/ thepathrow (~(got by paths.state) t.t.path) :: if the @da they passed was behind, %give them the current version, and %kick them ?: (gth updated-at.thepathrow t) - ~& >>> "{} tried to sub on old @da {}, %kicking them" + ::~& >>> "{} tried to sub on old @da {}, %kicking them" =/ thepeers (~(got by peers.state) t.t.path) =/ tbls (tables-by-path:db tables.state t.t.path) =/ dels=(list [@da db-del-change]) @@ -151,7 +153,7 @@ ::=/ thepathrow (~(get by paths-table.state) t.t.path) :::~ [%give %fact ~ chat-path-row+!>(thepathrow)] ::== - ~& > "{(scow %p src.bowl)} subbed to {(spud path)}" + ::~& > "{(scow %p src.bowl)} subbed to {(spud path)}" ~ :: /vent/~zod/~2000.1.1 [%vent @ @ ~] :: poke response comes on this path @@ -209,32 +211,32 @@ ^- (quip card _this) ?+ wire ~&(wire ~&(sign !!)) [%remote-scry %callback ~] - ~& > "remote-scry/callback on-agent {<-.sign>}" - ~& +.sign + ::~& > "remote-scry/callback on-agent {<-.sign>}" + ::~& +.sign `this [%dbpoke ~] ?+ -.sign `this %poke-ack ?~ p.sign `this - ~& >>> "%db: {<(spat wire)>} dbpoke failed" - ~& >>> p.sign + ::~& >>> "%db: {<(spat wire)>} dbpoke failed" + ::~& >>> p.sign `this == [%selfpoke ~] ?+ -.sign `this %poke-ack ?~ p.sign `this - ~& >>> "%db: {<(spat wire)>} selfpoke failed" + ::~& >>> "%db: {<(spat wire)>} selfpoke failed" `this == [%spaces ~] ?+ -.sign !! %watch-ack ?~ p.sign %- (slog leaf+"{}: subscribed to spaces" ~) `this - ~& >>> "{}: spaces subscription failed" + ::~& >>> "{}: spaces subscription failed" `this %kick - ~& > "{}: spaces kicked us, resubscribing..." + ::~& > "{}: spaces kicked us, resubscribing..." :_ this :~ [%pass /spaces %agent [our.bowl %spaces] %watch /updates] == @@ -255,20 +257,20 @@ ?- -.sign %poke-ack ?~ p.sign `this - ~& >>> "%db: {<(spat wire)>} /next/[path] failed" - ~& >>> p.sign + ::~& >>> "%db: {<(spat wire)>} /next/[path] failed" + ::~& >>> p.sign `this %watch-ack ?~ p.sign `this - ~& >>> "{}: /next/[path] subscription failed" + ::~& >>> "{}: /next/[path] subscription failed" `this %kick =/ pathrow (~(get by paths.state) +.wire) ?: =(~ pathrow) - ~& >>> "got a %kick on {(spud +.wire)} that we are ignoring because that path is not in our state" + ::~& >>> "got a %kick on {(spud +.wire)} that we are ignoring because that path is not in our state" `this =/ newpath (weld /next/(scot %da updated-at:(need pathrow)) path:(need pathrow)) - ~& > "{}: /next/[path] kicked us, resubbing {(spud newpath)}" + ::~& > "{}: /next/[path] kicked us, resubbing {(spud newpath)}" :_ this :~ [%pass wire %agent [src.bowl dap.bowl] %watch newpath] @@ -280,7 +282,7 @@ ^- (quip card state-0) =/ dbpath=path +.wire =/ factmark -.+.sign - ~& >> "%fact on {(spud wire)}: {}" + ::~& >> "%fact on {(spud wire)}: {}" ?+ factmark :: default case: ~& >>> "UNHANDLED FACT type" @@ -307,7 +309,7 @@ ?> ?=(%relay -.data.row.change) =/ uobj=(unit row) (get-db:db type.data.row.change path.data.row.change id.data.row.change state) ?~ uobj :: if we DONT have the obj already, remote-scry it - ~& >>> "asking for remote-scry" + ::~& >>> "asking for remote-scry" :~ [ %pass /remote-scry/callback @@ -323,7 +325,7 @@ ?. ?=(%relay type.row.change) ~ ?> ?=(%relay -.data.row.change) ?: deleted.data.row.change ~ :: if the root-obj is deleted, don't remote-scry it - ~& >>> "asking for remote-scry" + ::~& >>> "asking for remote-scry" :~ [ %pass /remote-scry/callback @@ -392,7 +394,7 @@ ?=(%relay -.data.row.change) =(%.y deleted.data.row.change) == - ~& >>> "{} is del-db ing {} {} {}" + ::~& >>> "{} is del-db ing {} {} {}" (del-db:db type.data.row.change path.data.row.change id.data.row.change state (add now.bowl index)) state $(index +(index), state (process-db-change:db dbpath change state bowl), result-cards (weld (weld result-cards new-scry) pokes)) @@ -436,15 +438,15 @@ ?- -.sign %poke-ack ?~ p.sign `this - ~& >>> "%realm-chat: {<(spat wire)>} dbpoke failed" - ~& >>> p.sign + ::~& >>> "%realm-chat: {<(spat wire)>} dbpoke failed" + ::~& >>> p.sign `this %watch-ack ?~ p.sign `this - ~& >>> "{}: /db subscription failed" + ::~& >>> "{}: /db subscription failed" `this %kick - ~& > "{}: /db kicked us, resubscribing..." + ::~& > "{}: /db kicked us, resubscribing..." :_ this :~ [%pass /db %agent [our.bowl %chat-db] %watch /db] @@ -457,7 +459,7 @@ ++ on-leave |= =path ^- (quip card _this) - ~& "Unsubscribe by: {} on: {}" + ::~& "Unsubscribe by: {} on: {}" `this :: ++ on-arvo @@ -465,7 +467,7 @@ ^- (quip card _this) ?+ wire !! [%remote-scry %callback ~] - ~& > "remote-scry/callback on-arvo" + ::~& > "remote-scry/callback on-arvo" ?+ -.sign-arvo `this %ames ?+ -.+.sign-arvo `this @@ -486,8 +488,8 @@ == == [%remote-scry %cullback ~] - ~& > "remote-scry cullback we culled something" - ~& > -.sign-arvo + ::~& > "remote-scry cullback we culled something" + ::~& > -.sign-arvo `this [%timer ~] ~& >>> "unhandled on-arvo %timer" diff --git a/desks/realm/lib/db.hoon b/desks/realm/lib/db.hoon index e9f86023d8..f2516a8e1f 100644 --- a/desks/realm/lib/db.hoon +++ b/desks/realm/lib/db.hoon @@ -8,6 +8,11 @@ :: :: helpers :: +++ maybe-log + |= [hide-debug=? msg=*] + ?: =(%.y hide-debug) ~ + ~& msg + ~ ++ got-db |= [=type:common =path =id:common state=state-0] ^- row @@ -602,7 +607,7 @@ :: %initiate, every ship in the members list, regardless of role or joined status |= [[=path sp=[=ship space=cord] sr=role:mstore] state=state-0 =bowl:gall] ^- (quip card state-0) - ~& %create-from-space + =/ log1 (maybe-log hide-logs.state %create-from-space) =/ members .^(view:mstore %gx /(scot %p our.bowl)/spaces/(scot %da now.bowl)/(scot %p ship.sp)/(scot %tas space.sp)/members/noun) ?> ?=(%members -.members) =/ filtered-members @@ -745,7 +750,7 @@ :: kick subs to force them to re-sub for next update [%give %kick [path-sub-wire ~] ~] == - ~& > "publishing to {(spud path-sub-wire)} (and also kicking)" + =/ log1 (maybe-log hide-logs.state "publishing to {(spud path-sub-wire)} (and also kicking)") [cards state] :: @@ -770,8 +775,8 @@ :: kick subs to force them to re-sub for next update [%give %kick [path-sub-wire ~] ~] == - ~& > "poking %delete-path to {(scow %p ship)}" - ~& > "publishing to {(spud path-sub-wire)} (and also kicking those subs)" + =/ log1 (maybe-log hide-logs.state "poking %delete-path to {(scow %p ship)}") + =/ log2 (maybe-log hide-logs.state "publishing to {(spud path-sub-wire)} (and also kicking those subs)") :: local state updates :: update paths table @@ -787,7 +792,7 @@ ++ get-path |= [[=path-row peers=ship-roles] state=state-0 =bowl:gall] ^- (quip card state-0) - ~& "%get-path {}" + =/ log1 (maybe-log hide-logs.state "%get-path {}") :: ensure the path doesn't already exist =/ pre-existing (~(get by paths.state) path.path-row) ?> =(~ pre-existing) @@ -833,8 +838,8 @@ (weld /next/(scot %da updated-at.path-row) path.path-row) ] == - ~& > "subbing to" - ~& > subs + =/ log1 (maybe-log hide-logs.state "subbing to") + =/ log2 (maybe-log hide-logs.state subs) =/ cards=(list card) (weld subs sub-facts) [cards state] :: @@ -842,12 +847,12 @@ |= [=path state=state-0 =bowl:gall] ^- (quip card state-0) :: ensure the path actually exists - ~& >>> "attempting to delete {}" + =/ log1 (maybe-log hide-logs.state "attempting to delete {}") =/ path-row=path-row (~(got by paths.state) path) :: ensure this came from host ship ?> =(host.path-row src.bowl) - ~& > "we either got kicked or the host deleted the whole path: {(spud path)}" + =/ log2 (maybe-log hide-logs.state "we either got kicked or the host deleted the whole path: {(spud path)}") :: remove from paths table, and peers table =. paths.state (~(del by paths.state) path) @@ -887,16 +892,16 @@ :: ensure the path actually exists =/ path-row=path-row (~(got by paths.state) path.row) ?. (has-create-permissions path-row row state bowl) - ~& >>> "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they didn't have permissions" + =/ log1 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they didn't have permissions") [~[kickcard] state] :: forward the request if we aren't the host ?. =(host.path-row our.bowl) - ~& >> "{} tried to have us ({}) create a row in {} where we are not the host. forwarding the poke to the host: {}" + =/ log2 (maybe-log hide-logs.state "{} tried to have us ({}) create a row in {} where we are not the host. forwarding the poke to the host: {}") :_ state [%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%create req-id input-row])]~ :: ensure that the row meets constraints ?. (meets-constraints path-row row state bowl) - ~& >>> "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they violated constraints" + =/ log3 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to create a %{(scow %tas type.row)} row where they violated constraints") [~[kickcard] state] :: update path @@ -917,7 +922,7 @@ [%give %fact ~[vent-path] db-vent+!>([%row row schema.input-row])] kickcard == - ~& > "publishing new row to {(spud path-sub-wire)} (and also kicking)" + =/ log4 (maybe-log hide-logs.state "publishing new row to {(spud path-sub-wire)} (and also kicking)") [cards state] :: @@ -925,17 +930,17 @@ :: generally, you'd only bother passing the schema if you are changing the version of the row ::db &db-action [%edit [our ~2023.5.22..17.21.47..9d73] /example %foo 0 [%general ~[2 'b']] ~] |= [[=id:common =input-row] state=state-0 =bowl:gall] - ~& "%bedrock agent - %edit poke" + =/ log1 (maybe-log hide-logs.state "%bedrock agent - %edit poke") ^- (quip card state-0) :: permissions =/ old-row (~(got by (~(got by (~(got by tables.state) type.input-row)) path.input-row)) id) :: old row must first exist =/ path-row=path-row (~(got by paths.state) path.input-row) ?. (has-edit-permissions path-row old-row state bowl) - ~& >>> "{(scow %p src.bowl)} tried to edit a %{(scow %tas type.input-row)} row where they didn't have permissions" + =/ log2 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to edit a %{(scow %tas type.input-row)} row where they didn't have permissions") `state :: forward the request if we aren't the host ?. =(host.path-row our.bowl) - ~& >> "{} tried to have us ({}) edit a row in {} where we are not the host. forwarding the poke to the host: {}" + =/ log3 (maybe-log hide-logs.state "{} tried to have us ({}) edit a row in {} where we are not the host. forwarding the poke to the host: {}") :_ state [%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%edit id input-row])]~ @@ -973,7 +978,7 @@ :: kick subs to force them to re-sub for next update [%give %kick [path-sub-wire ~] ~] == - ~& > "publishing edited row to {(spud path-sub-wire)} and kicking everyone there" + =/ log4 (maybe-log hide-logs.state "publishing edited row to {(spud path-sub-wire)} and kicking everyone there") [cards state] :: @@ -987,11 +992,11 @@ =/ old-row (~(got by tbl) id) :: old row must first exist =/ path-row=path-row (~(got by paths.state) path) ?. (has-delete-permissions path-row old-row state bowl) - ~& >>> "{(scow %p src.bowl)} tried to delete a %{(scow %tas type)} row where they didn't have permissions" + =/ log1 (maybe-log hide-logs.state "{(scow %p src.bowl)} tried to delete a %{(scow %tas type)} row where they didn't have permissions") `state :: forward the request if we aren't the host ?. =(host.path-row our.bowl) - ~& >> "{} tried to have us ({}) remove a row in {} where we are not the host. forwarding the poke to the host: {}" + =/ log2 (maybe-log hide-logs.state "{} tried to have us ({}) remove a row in {} where we are not the host. forwarding the poke to the host: {}") :_ state [%pass /dbpoke %agent [host.path-row dap.bowl] %poke %db-action !>([%remove type path id])]~ @@ -1016,7 +1021,7 @@ :: kick foreign ship subs to force them to re-sub for next update [%give %kick [foreign-ship-sub-wire ~] ~] == - ~& > "publishing %del-row type: {} id: {} to {(spud foreign-ship-sub-wire)} + kicking those subs" + =/ log3 (maybe-log hide-logs.state "publishing %del-row type: {} id: {} to {(spud foreign-ship-sub-wire)} + kicking those subs") [cards state] :: @@ -1026,7 +1031,7 @@ ::bedrock &db-action [%relay [~bus now] /target %relay 0 [%relay [~zod ~2023.6.13..15.57.34..aa97] %foo /example 0 %all %.n] ~] |= [[=req-id =input-row] state=state-0 =bowl:gall] ^- (quip card state-0) - ~& %relay + =/ log1 (maybe-log hide-logs.state %relay) :: first check that the input is actually a %relay ?+ -.data.input-row !! %relay @@ -1055,6 +1060,11 @@ == == :: +++ toggle-hide-logs + |= [toggle=? state=state-0 =bowl:gall] + ^- (quip card state-0) + =. hide-logs.state toggle + `state :: on-init selfpoke ++ create-initial-spaces-paths |= [state=state-0 =bowl:gall] diff --git a/desks/realm/sur/db.hoon b/desks/realm/sur/db.hoon index 6b3ddd3667..7ec9c2c2c8 100644 --- a/desks/realm/sur/db.hoon +++ b/desks/realm/sur/db.hoon @@ -11,6 +11,7 @@ =paths =peers =del-log + hide-logs=? :: default hidden %.y == +$ schemas (map [=type:common v=@ud] schema) @@ -155,6 +156,8 @@ [%remove =type:common =path =id:common] :: %host deleting the row, sends %delete to all peers [%relay =req-id =input-row] :: like %create, but for creating a %relay (relay:common) [%create-initial-spaces-paths ~] + + [%toggle-hide-logs toggle=?] == :: +$ ship-roles (list [s=@p =role])