Note: The download package has been updated with a new version of the action. The action now includes the workflow id, the path to the workflow and the current workflow execution token id to help tally logs sent to a webservice with an execution context on the server. Thanks go to Sam Perrin for the idea

 

Back in 2018, there was a great post written on the SimplyGeek blog that provided a simple reusable logging action for VMware vRO. It was (and still) is excellent and I’ve used it quite a few times. But lately, I’ve wanted something a bit more feature rich. So, as a famous singer once sung I decided it was time I took what I had an enhanced it.

“I did it my way..”

Based off of the original post by Gavin Stephens at SimplyGeek, I rewrote the bulk of the action to allow the following functionality

  • Always additionally log to the normal VMware vRO logs – this is automatically done with my logger, to the relevant log (and was the main point of Gavins original action)
  • Enable you to have a single ‘log object’ that can be written to, searched and used throughout the whole of your workflow execution
  • Have a log file that at the end of a workflow execution, you could immediately post back to a webservice somewhere, with the minimum of fuss
  • Allow you to search for log entries so [perhaps] your workflow could try and fix things that went wrong earlier!
  • Allow you to search for entries in the log file by type, by the title, or by their id

 

Lets See It Then!

First things first. Import the package. This will bring the action into inventory and also provide a simple example workflow, which I will run through here!

As you can see in the example workflow, I have created an attribute called ‘log.’ The type needs to be set to ‘Any.’

To use the LogManager, I have to pass the log attribute as an input into each of my workflow components(scripts, sub-workflows, actions etc.), remembering to also set it as an output for the component. We need to set it as an output as we are going to be using the same log instance throughout our workflows execution. The example workflow contains a script where we use the LogManager to write information to our log (see screenshot below).

 

First we have to instantiate an instance of the Logger action. We do that in the first line of our script object, as shown in the below screenshot. As you can see we pass in our log object (our ‘log’ attribute).

Next, we create a LogManager instanceNow we are finally ready to start creating some log entries. As you can see below, called the relevant Writexyz method on the logManager instance. Pass in a title for the log entry, followed by more information, so as a stack trace message. Each time you write to the log object, you will also write an entry in to the normal VMware vRO log (relevant to which Writexyz method you call).

When you want to view the full contents of the ‘log’ object, you can simply output it; the log file is a JSON object after all. So, using the example above, the output would look as below.

There are three search functions available as well. You can see them in the screenshot below.

Import the package and have a look at the action and the example workflow. And if you extend it and make it better please let me know!

Download the LogManager Package Here

 

 

 

 

 

 

 

 

 

paul_davey

CIO at Sonar, Automation Practice Lead at Xtravirt and guitarist in The Waders. Loves IT, automation, programming, music