The Perfect Abstractions development team recently released an Ignition project that enables people to easily see the wrapper.log file in a client or designer.
This project solves the problem of not having remote access to an Ignition server in order to view the wrapper.log file. But even with remote access to an Ignition server, this project makes it easier to access and view the wrapper.log file.
One caveat is that that importing the script will overwrite whatever you may already have in the project (Nick had warned me of it, and I think it’s mentioned in his blog post. But it is worth a re-mention ).
I imported into a standalone project. From there, I can copy/paste as needed.
Uploading/importing the WrapperLogViewer.proj as a standalone project and then copy/paste the wrapper.log viewer window into other projects is a good idea.
I didn’t even hear the horn before I was tossed under the bus.
This is the (slightly modified for v8) script that the project was based on. Adjust file and tag paths accordingly. It writes to a string tag and a date tag.
import os
import datetime
import sys
path = "/usr/local/bin/ignition/logs/wrapper.log"
tagPaths = ["WrapperLog/LogContent", "WrapperLog/LastModified"]
t = os.path.getmtime(path)
modified = datetime.datetime.fromtimestamp(t)
lastModified = system.tag.readBlocking([tagPaths[1]])[0]
if lastModified.value == None:
from java.util import Date
lastModified.value = Date(0)
def datetimeToJavaDate(value):
from java.util import Calendar, GregorianCalendar
cal = GregorianCalendar(value.year, value.month - 1, value.day,
value.hour, value.minute, value.second)
cal.set (Calendar.MILLISECOND, value.microsecond / 1000)
return cal.getTime()
if lastModified.value.before(datetimeToJavaDate(modified)):
content = system.file.readFileAsString(path)
if len(content) > 64000:
content = content[-64000:]
system.tag.writeBlocking(tagPaths, [content, modified])