Debugging with Bright Script Logger

24 / Jul / 2023 by Sharooque Naushad 0 comments

Logs are always very useful for software developers. It helps developers identify the problems & issues with their programs. Logs help them print data on the console & debug their code.

Are logs really that easy to use 

Logs seem pretty much handy, but there are some problems too with logs, and one of the biggest problems developers face with logs is that logs make your apps slow & heavy in size. It usually happens when you use too many logs and keep them alive in production. 

Logs can(if not used properly):

  • Degrade the performance of your application.

  • Make your app heavier in size.

  • Make you go here and there in your code to identify any specific log/print statement.

Developers usually remove logs from their code but it’s actually a time taking & complex process. Because it has to be done manually by browsing every single file. Bright Script Loggers come to the rescue here.

What is a BS Logger

Instead of writing logs in every single file, you can put all your logs in a single file only, and those logs are wrapped by functions/subs. This file can be included in any of your other files, and methods written in logger file can be called easily from anywhere in your application. So a Bright Script Logger is just a .brs file containing some methods that log your data. You can put any no of methods in this logger file. Here’s a demo.

Benefits of using BS Loggers

Loggers have got following advantages over using logs in different files in your application:

  • You’ve got a single file only to put & look around your logs in your app.
  • Loggers are accessible anywhere in your project.
  • Loggers eliminate your problem of removing logs from your application before releasing your app to production. You can simply comment your few methods written in Logger.
  • Loggers are pretty easy to use and require less code to execute.

Conclusion: So, looking at the discussion we had above, we can state that Loggers have come up with very good advantages and it’s a powerful tool to look around your code. It actually allows you to debug your code in a better way and off course, it is time saving and easy to use.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *