I have to admit, I'm a big fan of automation scripts.
Recent updates released with Maximo 22.214.171.124 have almost covered all the possible customization needs including library scripts, REST APIs, MIF processing, before/after save event. All the new features are well documented in this somewhat secret document.
However whatever nice feature will be added in the next feature pack, we will never have a debugger like we have with Java and Eclipse. This could be a serious problem when you have to develop and maintain a complex set of scripts in your environment.
The best way to mitigate such problem is to correctly use Maximo logging APIs.
In my projects I usually define a custom logger in the Logging application. It's a good practice to give a short name of your customer. In this example I have defined mxdev logger for my MaximoDev customer.
I can now log messages to this custom logger using Maximo APIs. In the following example I first import the MXLoggerFactory class, then I get the reference to my mxdev logger and then I use the MxLogger APIs to write messages in the system log.
from psdi.util.logging import MXLoggerFactory
logger = MXLoggerFactory.getLogger("maximo.mxdev")
logger.info("Entering SR_INIT script for ticket " + mbo.getString("TICKETID"))
logger.debug("This is a debug message")
There are several good reasons for doing that.
- I can select the logging level of my scripts dynamically in the Logger applications. I typically have that set to DEBUG in development and test environment. In production I set that to WARN or INFO to reduce verbosity.
- Logging is always a good way of commenting the code.
- It allows me to search for a specific string in the scripts when I see strange behaviors in the logs.
Labels: advanced, logging, scripting