Debug with log entries

When developing hooks, you can use log entries to debug issues and track your hook's execution. Cloudhooks supports standard Node.js logging methods for debugging purposes.

You can use two main logging methods:

Here is a hook example with logging:

module.exports = async function (payload, actions) {
  const { data } = await actions.http.get('https://cloudhooks.dev');

  if (data.length > 50*1024) {
    console.log('Downloaded data is more than 50kb!');
  }
}

This is the output of the test run:

Best practices:

  • Use descriptive log messages that help identify where the issue occurred
  • Include relevant variables or error information in your logs
  • Use console.error() for actual errors and console.log() for informational messages
  • Consider adding timestamps or sequence indicators in complex workflows
  • Remove or comment out debug logs before deploying to production