Transaction

3F35E4C1D2F226…C2D4BE592F89

Block 25,915 · index 0 · indexed

Summary

Hash
3F35E4C1D2F2266F1DE5F1241FE2AE345649BE1D002392BB604DC2D4BE592F89
Block
25,915
Size
4122 bytes
Gas used
9,568,212 / 11,481,914
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

#1AddPackagegno.land/p/moul/debug/v09 arguments

Arguments · 9

  1. #1debug
  2. #2README.md
  3. #3# `gno.land/p/moul/debug/v0` _TODO: describe this package._ <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:** ![gno.land/p/moul/debug/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/debug/v0/deps.png) > ⚠️ **Disclaimer:** provided as-is, without warranty; not security-audited. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
  4. #4debug.gno
  5. #5// 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`. package debug import ( "chain/runtime" "chain/runtime/unsafe" "time" "gno.land/p/moul/md/v0" "gno.land/p/moul/mdtable/v0" "gno.land/p/moul/realmpath/v0" "gno.land/p/nt/ufmt/v0" ) // Debug encapsulates debug information, including logs and metadata. type Debug struct { Logs []string HideMetadata bool } // Log appends a new line of debug information to the Logs slice. func (d *Debug) Log(line string) { d.Logs = append(d.Logs, line) } // Render generates the debug content as a collapsible Markdown section. // It conditionally renders logs and metadata if enabled via the `?debug=1` query parameter. func (d Debug) Render(path string) string { if realmpath.Parse(path).Query.Get("debug") != "1" { return "" } var content string if d.Logs != nil { content += md.H3("Logs") content += md.BulletList(d.Logs) } if !d.HideMetadata { content += md.H3("Metadata") table := mdtable.Table{ Headers: []string{"Key", "Value"}, } table.Append([]string{"`std.CurrentRealm().PkgPath()`", string(unsafe.CurrentRealm().PkgPath())}) table.Append([]string{"`std.CurrentRealm().Address()`", string(unsafe.CurrentRealm().Address())}) table.Append([]string{"`std.PreviousRealm().PkgPath()`", string(unsafe.PreviousRealm().PkgPath())}) table.Append([]string{"`std.PreviousRealm().Address()`", string(unsafe.PreviousRealm().Address())}) table.Append([]string{"`std.ChainHeight()`", ufmt.Sprintf("%d", runtime.ChainHeight())}) table.Append([]string{"`time.Now().Format(time.RFC3339)`", time.Now().Format(time.RFC3339)}) content += table.String() } if content == "" { return "" } return md.CollapsibleSection("debug", content) } // 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. func Render(path string) string { return Debug{}.Render(path) } // IsEnabled checks if the `?debug=1` query parameter is set in the given path. // Returns true if debugging is enabled, otherwise false. func IsEnabled(path string) bool { req := realmpath.Parse(path) return req.Query.Get("debug") == "1" } // 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. func ToggleURL(path string) string { req := realmpath.Parse(path) if IsEnabled(path) { req.Query.Del("debug") } else { req.Query.Add("debug", "1") } return req.String() }
  6. #6gnomod.toml
  7. #7module = "gno.land/p/moul/debug/v0" gno = "0.9"
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

msg:0,success:true,log:,events:[]

← Back to block 25,915