func IsEnabled
IsEnabled checks if the `?debug=1` query parameter is set in the given path. Returns true if debugging is enabled, otherwise false.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package debug provides utilities for logging and displaying debug information within Gno realms. It supports conditio...
gno.land/p/nym-moultest123/debugA 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.
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.
Package debug provides utilities for logging and displaying debug information within Gno realms. It supports conditional rendering of logs and metadata, toggleable via query parameters.
Key Features: - Log collection and display using Markdown formatting. - Metadata display for realm path, address, and height. - Collapsible debug section for cleaner presentation. - Query-based debug toggle using `?debug=1`.
IsEnabled checks if the `?debug=1` query parameter is set in the given path. Returns true if debugging is enabled, otherwise false.
Render displays metadata about the current realm but does not display logs. This function uses a default Debug struct with metadata enabled and no logs.
ToggleURL modifies the given path's query string to toggle the `?debug=1` parameter. If debugging is currently enabled, it removes the parameter. If debugging is disabled, it adds the parameter.
Debug encapsulates debug information, including logs and metadata.