Logging in VMware vRO Just Got a Whole Lot Easier!
If you’re familiar with my previous blog posts, you’ll know that I’m a big fan of simplifying and enhancing existing tools to make them more feature-rich. In this post, I’ve taken the excellent logging action from Gavin Stephens at SimplyGeek and expanded its capabilities to provide even more functionality.
The original action was already very useful, but I wanted to take it to the next level. So, I rewrote the bulk of the action to include the following features:
* The ability to pass the log attribute as an input into each workflow component (scripts, sub-workflows, actions, etc.) and set it as an output for the component. This allows you to use the same log instance throughout your workflow’s execution.
* Support for three search functions (by title, by message, and by stack trace) to help you quickly find specific log entries.
To use the enhanced LogManager, you’ll need to import the package and create an instance of the Logger action. Then, you can start creating log entries using the LogManager instance. Each time you write to the log object, you’ll also write an entry into the normal VMware vRO log.
Here’s an example workflow that demonstrates how to use the enhanced LogManager:
“`json
{
“name”: “Example Workflow”,
“description”: “A simple workflow that demonstrates the use of the LogManager action.”,
“version”: 1,
“inputs”: {
“log”: {
“type”: “Any”
}
},
“outputs”: {
“log”: {
“type”: “Any”
}
},
“tasks”: [
{
“name”: “Write Log”,
“action”: “LogManager”,
“inputs”: {
“log”: “log”
},
“outputs”: {
“log”: “log”
},
“script”: {
“language”: “javascript”,
“content”: “log.write(‘Hello, World!’);”
}
}
]
}
“`
In this example, we’re using the LogManager to write a log entry with the message “Hello, World!” Each time you run this workflow, you’ll see the log entry in the VMware vRO log.
To view the full contents of the ‘log’ object, simply output it. The log file is a JSON object, so you can use any JavaScript library to parse and display its contents.
I hope you find this enhanced LogManager action useful in your automation projects! If you have any questions or feedback, please don’t hesitate to reach out. And if you extend it further or make any improvements, I’d love to hear about it.
Download the LogManager Package Here
Happy automating!