Skip to content

Logging

Julian Waller edited this page Sep 29, 2022 · 3 revisions

You can write messages to the log in the admin ui of companion by calling this.log('info', 'Your message')

It is required that the message (2nd parameter) is a string, if it is not a string it will be converted to one, which can result in poor output if it was an object.

There are multiple levels that can be passed:

  • 'error' Use this when something went wrong, and you want to tell the user about it
  • 'warning' Use this when something a little wrong happened, but it shouldn't impact anything
  • 'info' Use this when you want to tell the user some information
    • Perhaps once connected you want to log the version of what you have connected to
  • 'debug' Use this to provide yourself extra information to aid in debugging

Note: The 'debug' level is currently always shown to the user, but this is expected to change so that it has to be enabled first. Feel free to be fairly noisy in how you use this, but remember that each message you write does have a cost.

You can also use console.log and similar functions. These are currently treated as an extra 'verbose' method that is only shown during development when companion is launched in the correct way. You should try to avoid using these.

Clone this wiki locally