Debug your new command and events functions using OpenWhisk.
1. Want to see how the actions are being triggered live?
- Go to terminal and run:
wsk activation poll
- Type
control c
to exit.
2. Want to get the logs of the most recent triggered action?
wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs wsk activation logs
2. Want to debug after the action is triggered?
-
Go to terminal and run:
wsk activation list --limit 1
You will see that the output is:
<some string> <name of the action currently debugging>
If, for example, you are testing a new command that you added, the action commands will be the name displayed.
-
You will see that there is a
String
before the name of the action. Copy thatString
. -
Now, run in terminal:
wsk activation get <the string you just copied>
You will see that a huge JSON object is printed out. You can see the response, the result and the logs inside that JSON object.
simulation of the 3 steps above:
**-macOS:Test **$ wsk activation list --limit 1 activations 42bb1fdd886f4a4780c82ae5ef7012bb commands **-macOS:Test **$ wsk activation get 42bb1fdd886f4a4780c82ae5ef7012bb
-
Make sure that you add
console.log(...)
inside your commands or events function, so that your task of reading the logs in the JSON object is helpful for you to figure out the bug 😜