One of my current project uses OpenWhisk, which is an open source serverless technology stack. IBM has it on their Bluemix platform, and since I work there, I get to play with it as much as I like! One thing that did seem clunky is that it takes more than one step to get the logs of the most recent function run via commandline – first you list the activations, then you request the logs of the activation you’re interested in. Of course, when you’re developing, that’s usually the most recent one so here’s my shortcut for that:
wsk activation list -l1 | tail -n1 | cut -d ' ' -f1 | xargs wsk activation logs
From left to right, sections separated by the pipe |
character, this is what happens:
- get a list of activations, limited to just one activation (it sorts the newest one first by default)
- grab only the last line of that output (there’s some extra titles and stuff in there)
- use the `cut` command with the space character as a field delimiter, and use only the first field (this gets the ID of the activation)
- get the logs of that activation
Of course it’s wrapped up in a script so I just run that from the commandline and check where I went wrong this time …