README.md
gno.land/p/moul/debug
A debug panel for realms: collect log lines while Render runs, then append
them as a collapsible section, but only when the reader asks for it with
?debug=1.
1func Render(path string) string {
2 var d debug.Debug
3 d.Log("loaded " + ufmt.Sprintf("%d", n) + " items")
4
5 out := renderPage()
6 out += d.Render(path) // empty unless ?debug=1
7 return out
8}
Without the query parameter the panel renders nothing, so the same code is safe to leave in a deployed realm: there is no debug build and no flag to flip.
API
1func (d *Debug) Log(line string) // append one line
2func (d Debug) Render(path string) string
3func Render(path string) string // metadata only, no logs
4func IsEnabled(path string) bool // is ?debug=1 set
5func ToggleURL(path string) string // same path with ?debug=1 added or removed
The struct is two fields, Logs []string and HideMetadata bool, so the zero
value already works and metadata is on unless you turn it off.
The metadata table reports the current realm's pkgpath and address, the
previous realm's pkgpath and address, the block height, and time.Now(). Those
six are what you need first when a realm behaves differently on chain than it
did in a test, and the previous-realm pair in particular is what a cross-realm
permission bug looks like.
ToggleURL is there so the page can render its own "debug" link:
1out += md.Link("debug", debug.ToggleURL(path))
Logs cost nothing on chain: they are built during a Render query and thrown
away with it. Do not call Log from a transaction path expecting persistence.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
Dependency graph:

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.