In this tutorial, I will tell you how to use logger using Brighscript in Roku and This is a logger function for Roku written in Brighscript with a small, function which provides utility on top of the Print function.

You can write and view your logs on the terminal using telnet via this command.

telnet roku-ip-address 8085

With the help of log you can write to your custom message on the console.

only String format arguments are supported!

m.log.d("debug");
m.log.e("error");
m.log.w("warning");
m.log.v("verbose");
m.log.i("information");
m.log.f("Terrible Failure");

Write This function into Log.brs and import into your scene.

function RokuLogger(category_ = "Log" as String) as Object
  return {
    _category : category_,

    i  : function(message as String, args = invalid) as Void
      m._log( 1, message, args )
    end function,

    d : function(message as String, args = invalid) as Void
      m._log( 2, message, args )
    end function,

    w  : function(message as String, args = invalid) as Void
      m._log( 3, message, args )
    end function,

    e : function(message as String, args = invalid) as Void
      m._log( 4, message, args )
    end function,

    f : function(message as String, args = invalid) as Void
      m._log( 5, message, args )
    end function,

    _log  : function(level_ as Integer, message as String, args = invalid) as Void
      ? "->>>>>>> ";m._category;" # ";message;

      if args = invalid then
        ? ""
      else
        ? " -->>>>> ";args
      end if
    end function
  }
end function

Initialize in Scene:

Function init() as Void 

  m.log = RokuLogger("appSceneComponentName")
  m.log.d("init()")

End Function

Usage:

 m.log.i("showDate()", data)
 m.log.i("Finish")
 m.log.i("handleStatus()", m.displayStatus)