::nsmcp::Object ::nsmcp::Object dict getdef ::nx::Object ::nx::Object ::nsmcp::Object->::nx::Object ::nsmcp::LogSummaryReader ::nsmcp::LogSummaryReader line next nextLine ::nsmcp::LogSummaryReader->::nsmcp::Object

Class ::nsmcp::LogSummaryReader

::nsmcp::LogSummaryReader[i] create ... \
           [ -buffer (default "") ] \
           [ -channel:required channel:required ] \
           [ -index (default "0") ] \
           [ -limit:required limit:required ] \
           [ -lookahead (default "") ] \
           [ -maxBytes:required maxBytes:required ] \
           [ -offset:required offset:required ]

Defined in /usr/local/ns/tcl/nsmcp/log-traffic-summary.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nsmcp::Object[i]
::nx::Class create ::nsmcp::LogSummaryReader \
     -superclass ::nsmcp::Object

Methods (to be applied on instances)

  • next (scripted, public)

     <instance of nsmcp::LogSummaryReader[i]> next

    Read the next logical system-log event. Combine supported continuation lines and retain lookahead for the following event.

    Returns:
    The event dictionary, or an empty result at end of input.

    Testcases:
    No testcase defined.
    if {${:lookahead} ne ""} {
        set line ${:lookahead}
        set :lookahead {}
    } else {
        set line [:line]
    }
    if {$line eq ""} {
        error "unexpected end of system log during summary scan"
    }
    set event [dict create offset [dict get $line start] endOffset [dict get $line end]  message [dict get $line text] truncated [dict get $line truncated] complete false]
    while {${:offset}<${:limit}} {
        set line [:line]
        if {$line eq ""} {
            break
        }
        if {![::nsmcp::logRecordParser continuation [dict get $event message] [dict get $line text]]} {
            set :lookahead $line
            dict set event complete true
            return $event
        }
        set text "\n[dict get $line text]"
        set room [expr {max(0,${:maxBytes}-[string length [dict get $event message]])}]
        if {[string length $text]>$room || [dict get $line truncated]} {
            dict set event truncated true
        }
        if {$room>0} {
            dict append event message [string range $text 0 [expr {$room-1}]]
        }
        dict set event endOffset [dict get $line end]
    }
    return $event
  • nextLine (scripted, public)

     <instance of nsmcp::LogSummaryReader[i]> nextLine

    Read the next physical line for an access-file scan. Delegate to the reader's bounded line source without logical-record assembly.

    Returns:
    The next line descriptor, or an empty result at exhaustion.

    Testcases:
    No testcase defined.
    return [:line]