Bright Script Logger

March 16, 2023 | Shishupal Shakya

Logs have always been a very useful tool for software developers.  Logs help developers debug their code. Developers can immediately identify the issues with their code by putting logs into certain files/methods. 

Problems with Logs – 

Logs come with some disadvantages too, logs may degrade the performance of your application. You’ll often see your app taking too much time in loading content and that, sometimes, happens because of too many logs.

 That’s why developers tend to remove logs from their code before releasing builds or pushing the apps to the store. Now removing logs from your code is a tedious process because there could be hundreds of logs in your code and removing them line by line will kill a huge amount of time and it’s never been a best practice. This is where Loggers come into existence. In this blog today, we’ll see what loggers are, how they help us with putting/removing logs, and how we can use them. Loggers are applicable to every platform/programming language but we’re especially targeting Roku/Bright Script developers in this blog and we’ll show how we can create and use loggers in a Roku project.

How to create Brightscript Logger? 

A logger is a simple file (.brs file for Roku developers) that contains generic functions for logging. These generic functions print your data. You can call these functions from anywhere in your project and data can be passed around as arguments to these functions. You can create these logger files in the same way you create a simple .brs file. The below image shows what a logger file looks like. 

Usage of Brightscript Loggers: 

You can simply call the methods written in the logger file with their names. For example, let’s say you’ve an associative array named myData and you want to print it.

myData = {“age”: 27, “name”: “Raj”}

You can print this data using the logData() method of logger in the following way :-


The output would be: *** Your Data is ***** 


age: 27

  name: Raj

Advantages of Loggers

Loggers come up with the following advantages: –

    • You don’t have to write print statements in every file of your project. 
    • You can access loggers anywhere in your project.
  • You don’t have to manually remove print statements from all of your files if you’re using loggers in your project. You just need to comment any of the three methods mentioned above and you’re done.
  • Loggers allow you to write less code and they’re easy to use.


With the features and benefits listed above, we can conclude that Loggers are a convenient way to print data in your apps. It helps save your time and you can simply debug your code using a single file only.