I am missing something here, do we have any docs on how the hooks works except the source code?
How to see what hooks are firing?
RogerLevy last edited by RogerLevy
I'm developing my first plugin and would like to see what hooks are firing. Can nodebb be configured to log all hooks?
Why do you want to see that? What for? If you just want a list of available hooks look at this page: https://github.com/NodeBB/NodeBB/wiki/Hooks
To get a shorter path to understanding when certain hooks fire.
Not a bad idea, https://github.com/NodeBB/NodeBB/commit/81341e86ee5e6ea839c3460199950128020ad018, run in dev mode or with
That might be a bit much even for verbose? One click gave me 87 lines of output that I can't post here because even Askimet thinks this is a bit spamy
It sure might be an interesting idea. But it also doesn't give a lot of information. For example it gives you no context information of the fired hooks. Why was it fired, for what was it fired, etc?
Maybe this could be configured to limit hook logs to a match a string. So you could tell it to log only "action" or "post" and that would control the spam
If you're on Linux this can be achieved. I'm at the moment doing this to exclude all of them:
./nodebb dev | grep -v "plugins/fireHook"
If you only want action hooks you could do something like this:
./nodebb dev | grep -v -e "plugins/fireHook] filter" -e "plugins/fireHook] static"
Probably somehow also possible with the PowerShell on Windows.
@dravere How would you achieve filtering out every "plugins/fireHook]" line that does NOT also have a certain string? (inclusion as opposed to exclusion)
If you want to filter for hooks you can just leave out the
-v. It will exclude every line others than the ones that include the pattern. For example:
./nodebb dev | grep "plugins/fireHook] filter:parse.post"
This would only show you lines that include this pattern. Again you can combine multiple patterns, just provide each via the
-eargument. For example:
./nodebb dev | grep -e "plugins/fireHook] filter:parse.post" -e "plugins/fireHook] filter:users.get"