Skip to content

Commit

Permalink
Log hook sequence to help devs debug
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMaz committed Jan 4, 2022
1 parent 127dd4d commit c235247
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dev/hook-wildcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
const ServiceBroker = require("../src/service-broker");

const broker = new ServiceBroker({
nodeID: "wildcard-hooks"
nodeID: "wildcard-hooks",

logLevel: "debug"
});

broker.createService({
Expand Down
14 changes: 14 additions & 0 deletions src/middlewares/action-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ module.exports = function actionHookMiddleware(broker) {
? sanitizeHooks(action.hooks.error, action.service)
: null;

// Show info for debugging purposes
broker.logger.debug(`Service Level 'Before' Hooks of '${name}' action:`, [
...(beforeAllHook ? ["*"] : []),
...(beforeHookMatches ? beforeHookMatches : [])
]);
broker.logger.debug(`Service Level 'After' Hooks of '${name}' action:`, [
...(afterAllHook ? ["*"] : []),
...(afterHookMatches ? afterHookMatches : [])
]);
broker.logger.debug(`Service Level 'Error' Hooks of '${name}' action:`, [
...(errorAllHook ? ["*"] : []),
...(errorHookMatches ? errorHookMatches : [])
]);

if (
beforeAllHook ||
beforeHook ||
Expand Down

0 comments on commit c235247

Please sign in to comment.