Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Use warning messages to debug automation scripts?

    Posted Mon December 06, 2021 09:16 PM
    Edited by System Admin Wed March 22, 2023 11:50 AM
    MAM 7.6.1.2:

    I was reading the 7.6.1.2 Java docs and noticed that the ScriptService class has a setWarning() method:
    setWarning(java.lang.String warnGrpVal, java.lang.String warnKeyVal, java.lang.String[] warnparams) 


    That made me wonder, can I use a warning message when debugging automation scripts? It looks like the answer is yes:
    x = []
    service.setWarning("", "the variable's value is: \n \n" + useWithConcat, x)​
    
    # The script continues to run after the warning pops up (after the user clicks OK). 
    # That seems more useful that what I was doing before -- using service.error(). The script  stops.


    I'm new to Python/autoscripts...is that a reasonable practice? How can I use the params properly?
    My case is pretty rare: I don't have access to the logs. So showing info from my scripts through a popup seems like an appealing option to me.
    #Maximo
    #AssetandFacilitiesManagement


  • 2.  RE: Use warning messages to debug automation scripts?

    Posted Tue December 07, 2021 02:44 AM
    I'm going to offer a piece of unsolicited advice.

    If you're trying to develop scripts, or as in multiple of your many other threads, debug escalations, cron tasks or do any form of debugging, log access is really the only way to go. I realize that your organization might be restrictive, but if your role includes those tasks you should be allowed log access - otherwise it's virtually impossible to efficiently do your job. 

    By trying what you're suggesting here (and for what it's worth, a bunch of the other workarounds you've mentioned in other threads), you're only digging yourself a deeper hole. 

    Work with your IT organization and implement proper logging. As usual Bruno has a good write-up. If they won't give you access to all the log files, have your logger output to a specific file that you're granted access to at the very least.

    Using the loggers as intended is great. I personally like to create child loggers with separate log files for some of the most business critical scripts, especially during development and debugging. That way I can isolate the logging from my particular script and efficiently go through the log file, get a feel for what's happening, and if needed I have an idea where to look in other logs for related errors or relevant messages. 
    Some great thoughts and practices are shared in another thread here from about a year ago.

    ------------------------------
    Henrik Christiansen
    ------------------------------



  • 3.  RE: Use warning messages to debug automation scripts?

    Posted Tue December 07, 2021 08:44 PM
    Edited by System Admin Wed March 22, 2023 11:50 AM