How to log from python?

Hi. What logging options are available for python scripts on a Transport WR41 gateway? Is there any way to log to the device’s main event log?


It depends what you are trying to achieve…

from BaseWizard import write_cli

eventlog = write_cli (“type eventlog.txt”)
print eventlog

or you could do

eventlog = open(“/eventlog.txt”)
eventlog_contents =
print (eventlog_contents)

I read it the other way around.

To write to the event log:

from BaseWizard import write_cli

eventlog =write_cli(‘setevent “this is a test”’)

1 Like

Thank you for replying. I get an error when trying to import BaseWizard:

ss200496>Python 2.6.1 (r261:67515, May 07 2013, 10:54:58) [C] on digiSarOS
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from BaseWizard import write_cli
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named BaseWizard

You must be on a super old version. What firmware are you running (“id” command)?

You can get the latest from here:

I was on version 5176. I’ve upgraded to and your code snippet is working. Thank you!!

In case this helps anyone, threw this together. Should work the same as any python logging handler.

class DigiEventLogHandler (logging.Handler):
	def __init__ (self):
		from BaseWizard import write_cli
		self.write_cli = write_cli

	def emit (self, record):
		if not hasattr(self, 'write_cli'):
		msg = self.format(record)
		self.write_cli('setevent "%s"' % msg)