nsmcp::LogService method results (public)
<instance of nsmcp::LogService> results context handle cursor \ limit includePeers
Defined in /usr/local/ns/tcl/nsmcp/log-tools.tcl
Read an owned log job's bounded result page. Apply pagination and require the additional peer permission when raw peer addresses are requested.
- Parameters:
- context (required)
- Authenticated request context carrying the principal, grants and selected server.
- handle (required)
- Retained job or conversation handle; ownership and expiry checks still apply.
- cursor (required)
- Zero-based cursor into retained results.
- limit (required)
- Maximum number of records or entries to return.
- includePeers (required)
- Whether raw peer addresses are requested; requires the additional peer permission.
- Returns:
- A rooted JSON result-page object.
- Testcases:
- No testcase defined.
Source code: :require $context if {$includePeers} { ${:authorizer} require $context diagnostics.logs.peers.read } set internal {} ns_mutex lock ${:mutex} try { foreach key [nsv_array names ${:store}] { set record [nsv_get ${:store} $key] if {[:owned $context $record] && [dict exists $record mappings $handle]} { set internal [dict get $record mappings $handle] break } } } finally { ns_mutex unlock ${:mutex} } if {$internal eq ""} { ns_mutex lock ${:mutex} try { foreach key [nsv_array names ${:store}] { set record [nsv_get ${:store} $key] if {![:owned $context $record]} { continue } if {$key eq $handle} { return -code error -errorcode {NSMCP RPC -32602} "This is a jobHandle; pass it as jobHandle to poll the job" } if {[dict exists $record windowHandle] && [dict get $record windowHandle] eq $handle} { return -code error -errorcode {NSMCP RPC -32602} "This is a windowHandle; use it with access_summary" } } } finally { ns_mutex unlock ${:mutex} } return -code error -errorcode {NSMCP RPC -32602} "Unknown or expired result handle" } set page [${:correlation} results $internal $cursor $limit] set policy [expr {$includePeers ? ${:peerRedactor} : ${:redactor}}] set page [$policy page $page] set records {} set index 0 foreach entry [dict get $page records] { set fields {} foreach key {timestamp processThread logThread severity requestIdentifier peerAddress method url protocol message pool timingSource recordSource driver phaseTimingReason recordType mutexName mutexOperation mutexMetric} { if {[dict exists $entry $key]} { lappend fields $key string [dict get $entry $key] } } foreach key {offset endOffset status responseBytes} { set value [dict get $entry $key] lappend fields $key [expr {$value eq "" ? "string" : "number"}] $value } foreach key {startTime acceptTime queueTime filterTime runTime mutexDurationSeconds mutexObservationCount mutexTotalSeconds} { if {[dict exists $entry $key]} { lappend fields $key number [dict get $entry $key] } } foreach key {requestIdentifierUnique phaseTimingAvailable mutexDeferred} { if {[dict exists $entry $key]} { lappend fields $key boolean [dict get $entry $key] } } foreach key {complete truncated orphanContinuation redacted} { lappend fields $key boolean [dict get $entry $key] } lappend records $index object $fields incr index } set data [list server string [ns_info server] resultHandle string $handle records array $records nextCursor string [dict get $page nextCursor]] foreach key {resultCount generation} { lappend data $key number [dict get $page $key] } foreach key {more scanIncomplete pending cacheFull} { lappend data $key boolean [dict get $page $key] } if {[dict exists $page limitReached]} { lappend data limitReached boolean [dict get $page limitReached] } return [list {} object $data]XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)