The roSystemLog component enables the application to receive events from the Roku Streaming Player that are intended for reporting errors and trends, rather than trigger a response to a user action.

Table of Contents

Supported Interfaces


The roSystemLog component requires specific Design Patterns in your BrightScript Application. Take care to:

  • Use one roMessagePort throughout the application (instead of creating a new roMessagePort for each screen)
  • Create one roSystemLog instance at startup that remains for the entire lifetime of the application.
  • Pass the global roMessagePort referenced in the first bullet point to SetMessagePort() on the roSystemLog component.
  • Enable the desired log types using EnableType()
  • Handle the roSystemLogEvents in all message loops.

 All of the log event messages are sent to the roMessagePort that is registered on the roSystemLog object.   See roSystemLogEvent for details on the messages.

This object is created with no parameters:



 Sub showVideoScreenWithLogging(item As Object)
     port = CreateObject("roMessagePort")
     vs = CreateObject("roVideoScreen")
     ' **** Metrics *****
     ' Create a SystemLog object for detailed HTTP information and
     ' periodic bandwidth measurements. The high level idea is to use
     ' the roVideoScreen events as the primary driver of the
     ' reporting and then to use the http.error and http.connect
     ' roSystemLogEvents for detailed information. In this case that
     ' detailed information is primarily the ip addresses. 
     syslog = CreateObject("roSystemLog")
     ' **** End Metrics ***** 
     metrics = CreateObject("roAssociativeArray")
     metrics.streamStartTimer = CreateObject("roTimespan")
     metrics.timeSpentBuffering = 0
     metrics.errorCount = 0
     While True
         If msg.isPlaybackPosition() Then
             If metrics.streamStartTimer <> invalid
                 duration = metrics.streamStartTimer.TotalMilliseconds()
                 dateTime = CreateObject("roDateTime").asSeconds()*1000
                 startTime = dateTime - duration
                 note = "Rebuferring"
                 if lastpos = 0 note ="Initial loading"
                 print "Report following prints via urls to your site"
                 print "Note is " ; note
                 print "Report startTime, buffering, duration, note"
             End If
         Elseif type(msg) = "roSystemLogEvent" Then
              ' Handle the roSystemLogEvents:
              i = msg.GetInfo()
              If i.LogType = "http.error" or i.LogType = "http.connect"
                  If i.LogType = "http.error" 
                      metrics.errorCount = metrics.errorCount + 1
                      print "http error: "; i.HttpCode; "URL: ";i.Url 
                  End If
                  url = i.OrigUrl
                  If (not httpIpAddrs.DoesExist(url)) Then
                      httpIpAddrs[url] = CreateObject("roAssociativeArray")
                  End If 
              Else If i.LogType = "bandwidth.minute"
                  metrics.bandwidth = i.Bandwidth
              End If
          End If 
          REM more event handling
     End While
 End Sub