Print text to Event Log

Posted on
Mon Jul 20, 2020 2:44 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Print text to Event Log

Assuming this is actually possible, I'm looking for a way to print certain text to the Event log.

I looked here https://pythonexamples.org/python-print-string-console-example/, and have searched the Python forum for "Print to Log", but haven't found anything. I have tried just this:

Code: Select all
print(hello!)
and
Code: Select all
print('Hello World!')

but using just the print command doesn't work.This would be part of a bigger Python script, and mainly want to notate when certain things happen in the log that is easier for me to look for.

Posted on
Mon Jul 20, 2020 2:49 pm
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Print text to Event Log

Presuming it is an embedded Indigo script or an external Indigo python script (being directly executed in an Indigo Action), then you'll want to use:

Code: Select all
indigo.server.log("Hello world!")

Image

Posted on
Mon Jul 20, 2020 3:59 pm
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Print text to Event Log

Hey Matt

Was sure it would be something easy.

thanks for your help.

Posted on
Mon Jul 20, 2020 7:59 pm
mclass offline
Posts: 314
Joined: May 13, 2015
Location: Melbourne, Australia

Re: Print text to Event Log

On a similar note, is it possible to change the colour of text in the log - I note some messages appear in red and green?


Sent from my iPad using Tapatalk

Posted on
Tue Jul 21, 2020 11:37 am
matt (support) offline
Site Admin
User avatar
Posts: 21416
Joined: Jan 27, 2003
Location: Texas

Re: Print text to Event Log

You can set isError=True as an optional argument and it will show in red. There is an example here.

Image

Posted on
Thu Mar 11, 2021 10:08 am
jltnol offline
Posts: 994
Joined: Oct 15, 2013

Re: Print text to Event Log

Once again, one of the things I LOVE about Indigo is the never ending level of help. While I had a question about this months ago, in updating my scripts, decided it would be helpful if they would appear in the log in red. I was easily able to find my old post here, only to find someone else had already asked my question, and gotten the answer, which helped me in my quest.

Thanks again to Matt and Jay and EVERYONE here who gives answers from the most simple, to the most complex. It is an amazing group of the most helpful tech people I've ever had the pleasure of dealing with.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest