Skip to content

SCR122: print-statement

print in a script that runs on the gateway

Code SCR122
Name print-statement
Category Scripts (SCR)
Default severity info
Enabled by default no
Fix available no
ign-lint equivalent none

Reports print statements in scripts that run on the gateway: gateway events, WebDev handlers, tag events, Perspective scripts (Perspective runs all Python on the gateway) and library modules. Vision client scripts are not reported.

On the gateway print goes to the wrapper log (wrapper.log), without a logger name, level or timestamp from the gateway's logging system, and cannot be filtered or viewed in the gateway's log page. Use a logger (system.util.getLogger("MyProject.Area")), or system.perspective.print(...) to write to the browser console of a Perspective session.

def onTagChange(initialChange, newValue, previousValue, event, executionCount):
print "new value", newValue.value

Use instead:

def onTagChange(initialChange, newValue, previousValue, event, executionCount):
system.util.getLogger("Plant.TagEvents").info("new value %s" % newValue.value)

Generated from the rule metadata by iglint generate-docs; iglint rule SCR122 prints the same page in the terminal. Source: docs/rules/SCR122.md.