summaryrefslogtreecommitdiff
path: root/doc/developer/scripting.rst
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-08-28 17:08:45 +0300
committerDonatas Abraitis <donatas@opensourcerouting.org>2024-08-28 17:08:45 +0300
commita0a2a35ed30938f99715cced352a3fd6f89d82dd (patch)
treea0da346fcc2cfc348bd36ce2c5a1b558bf80982d /doc/developer/scripting.rst
parentb1012b693fcfed29a05d99e8bea623902223dc7b (diff)
lib: Add a helper function to dump Lua stack
Very handy for debugging. In Lua script just use "log.trace(table)": ``` function on_rib_process_dplane_results(ctx) log.trace(ctx.rinfo.zd_ng) end ``` You will get something like: ``` Aug 28 17:04:36 donatas-laptop zebra[3782199]: [GCZ7N-MM9D9] { 1: { type: 2 weight: 1 flags: 5 backup_idx: 0 vrf_id: 0 nh_encap_type: 0 gate: { value: 5.87967e+08 string: "192.168.11.35" } nh_label_type: 0 srte_color: 0 ifindex: 0 backup_num: 0 } 2: { type: 3 weight: 1 flags: 3 backup_idx: 0 vrf_id: 0 nh_encap_type: 0 nh_label_type: 0 srte_color: 0 ifindex: 4 backup_num: 0 } } ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'doc/developer/scripting.rst')
-rw-r--r--doc/developer/scripting.rst5
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/developer/scripting.rst b/doc/developer/scripting.rst
index 7a43314490..f51130b1e3 100644
--- a/doc/developer/scripting.rst
+++ b/doc/developer/scripting.rst
@@ -523,6 +523,7 @@ object which contains methods corresponding to each of the ``zlog`` levels:
log.error("error")
log.notice("notice")
log.debug("debug")
+ log.trace("trace")
The log messages will show up in the daemon's log output.
@@ -579,14 +580,14 @@ accomplished with scripting.
RM_FAILURE, RM_NOMATCH, RM_MATCH, RM_MATCH_AND_CHANGE)
log.info("Evaluating route " .. prefix.network .. " from peer " .. peer.remote_id.string)
-
+
function on_match (prefix, attributes)
log.info("Match")
return {
attributes = RM_MATCH
}
end
-
+
function on_nomatch (prefix, attributes)
log.info("No match")
return {