2

Hi I am writing an automation script in Maximo that fires on a cron task. I am having trouble inserting a line break in my print statement. I have tried '\n' & just adding a print() in between my prints. Neither are working and all my prints are being packed into one line in my log file.

Quinn
  • 89
  • 2
  • 10
  • How are you viewing your log file? `\n` usually works for me, and I view my logs with Notepad++. Maybe you need to look at your logs using a different tool. – Preacher Nov 20 '19 at 20:36
  • I am using notepad++ as well – Quinn Nov 21 '19 at 14:20
  • I don't know if this will help, but if I go to `Settings` > `Preferences` > `New Document`, my `Format (Line ending)` is set to `Windows (CR LF)`. Also, on the `Edit` menu I found the `EOL Conversion` submenu which you might find helpful. – Preacher Nov 21 '19 at 15:40

2 Answers2

5

You could instead use the provided log() method on the service implicit variable to achieve the same result. Every call will generate a line in your log file. https://www.ibm.com/support/knowledgecenter/SSLLAM_7.6.0/com.ibm.mbs.doc/autoscript/r_variables_automation_scripts.html

Also, if you want more control on the log levels, you can get a logger directly from the Logger API which is basically a Log4J wrapper:

from psdi.util.logging import MXLoggerFactory

logger = MXLoggerFactory.getLogger("maximo.integration")
logger.info("Integration logger used from automation script")

You would then control its log level from the Logging application.

JPTremblay
  • 900
  • 5
  • 8
0

Using the log() method will achieve the correct result. If you also do want to still use print I have found out \n will only work if it is preceded by \r in a Maximo automation script like '\r\n'

Quinn
  • 89
  • 2
  • 10