mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Better hook debug printout
This commit is contained in:
parent
a5245c896a
commit
1c0734e97b
3 changed files with 23 additions and 5 deletions
|
@ -5,7 +5,7 @@ var async = require("async");
|
|||
var hookCallWrapper = function (hook, hook_name, args, cb) {
|
||||
if (cb === undefined) cb = function (x) { return x; };
|
||||
try {
|
||||
return hook.hook(hook_name, args, cb);
|
||||
return hook.hook_fn(hook_name, args, cb);
|
||||
} catch (ex) {
|
||||
console.error([hook_name, hook.part.full_name, ex]);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,24 @@ exports.update = function (cb) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.formatPlugins = function () {
|
||||
return Object.keys(exports.plugins).join(", ");
|
||||
}
|
||||
|
||||
exports.formatParts = function () {
|
||||
return exports.parts.map(function (part) { return part.full_name; }).join("\n");
|
||||
}
|
||||
|
||||
exports.formatHooks = function () {
|
||||
var res = [];
|
||||
Object.keys(exports.hooks).forEach(function (hook_name) {
|
||||
exports.hooks[hook_name].forEach(function (hook) {
|
||||
res.push(hook.hook_name + ": " + hook.hook_fn_name + " from " + hook.part.full_name);
|
||||
});
|
||||
});
|
||||
return res.join("\n");
|
||||
}
|
||||
|
||||
exports.getPlugins = function (cb) {
|
||||
exports.getPackages(function (er, packages) {
|
||||
packages.__builtin__ = {
|
||||
|
@ -82,7 +100,7 @@ exports.extractHooks = function (parts) {
|
|||
var hook_fn_name = part.hooks[hook_name];
|
||||
var hook_fn = exports.loadFn(part.hooks[hook_name]);
|
||||
if (hook_fn) {
|
||||
hooks[hook_name].push({"hook": hook_fn, "part": part});
|
||||
hooks[hook_name].push({"hook_name": hook_name, "hook_fn": hook_fn, "hook_fn_name": hook_fn_name, "part": part});
|
||||
} else {
|
||||
console.error("Unable to load hook function for " + part.full_name + " for hook " + hook_name + ": " + part.hooks[hook_name]);
|
||||
}
|
||||
|
|
|
@ -79,9 +79,9 @@ async.waterfall([
|
|||
plugins.update,
|
||||
|
||||
function (callback) {
|
||||
console.log(["plugins", plugins.plugins]);
|
||||
console.log(["parts", plugins.parts]);
|
||||
console.log(["hooks", plugins.hooks]);
|
||||
console.log("Installed plugins: " + plugins.formatPlugins());
|
||||
console.log("Installed parts:\n" + plugins.formatParts());
|
||||
console.log("Installed hooks:\n" + plugins.formatHooks());
|
||||
callback();
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue