Skip to content
Donate

Logging Guide (roku-log)

JellyRock uses roku-log for structured, flexible logging. Follow these steps to set up and use logging effectively.

Call log.initializeLogManager as early as possible (after SceneGraph starts):

m.top._rLog = log.initializeLogManager([
"log_PrintTransport", "log_ScreenTransport"
], 5)
  • Transports: Choose one or more:
    • log_PrintTransport (telnet output)
    • log_ScreenTransport (overlay screen)
    • log_NodeTransport (RALE node)
    • log_HTTPTransport (HTTP endpoint)
  • Log Level: 1=error, 2=warn, 3=info, 4=verbose, 5=debug

In every .bs file that uses logging, import the mixin:

import "pkg:/source/roku_modules/log/LogMixin.brs"

3. Register a Logger in Each Component/Class

Section titled “3. Register a Logger in Each Component/Class”

In your component’s init() method:

sub init()
m.log = new log.Logger("MyComponent")
end sub

Or your class’s new() method:

class AnalyticsManager
function new()
m.log = new log.Logger("AnalyticsManager")
end function
end class

Use these methods for structured logging:

LevelUse ForExamples
m.log.errorCrashes & Critical FailuresAuth failure, server unreachable, video won’t play
m.log.warnIssues with FallbacksMissing data (using defaults), retry attempts, deprecated usage
m.log.infoImportant User EventsMajor app state changes, video start/stop, login success, etc.
m.log.verboseDetailed Operationsfunction entry/exit, API calls, data processing
m.log.debugVariable Values & LogicLoop contents, conditional branches, object dumps

All accept a message and up to 9 values:

m.log.info("Received data", json.result, "http call", m.top.uri)

No need to convert values to strings—roku-log handles this.

Use indentation helpers to group related log entries:

m.log.increaseIndent("Fetching user data")
' ...log actions...
m.log.decreaseIndent()
m.log.resetIndent()
  • increaseIndent([title]): Optional title for context
  • decreaseIndent(): Step out one level
  • resetIndent(): Clear all indentation
  • Initialize logging early to capture all events.
  • Import the mixin in every file that logs.
  • Create a logger per component/class for clear log sources.
  • Use appropriate log levels for filtering.
  • Group related actions with indentation for easier tracing.
  • Never use print statements outside of source/main.bs; always use roku-log.

This guide covers all essential steps and best practices for using roku-log in JellyRock.