Page 1 of 1

Print text to Event Log

PostPosted: Mon Jul 20, 2020 2:44 pm
by jltnol
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.

Re: Print text to Event Log

PostPosted: Mon Jul 20, 2020 2:49 pm
by matt (support)
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!")

Re: Print text to Event Log

PostPosted: Mon Jul 20, 2020 3:59 pm
by jltnol
Hey Matt

Was sure it would be something easy.

thanks for your help.

Re: Print text to Event Log

PostPosted: Mon Jul 20, 2020 7:59 pm
by mclass
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

Re: Print text to Event Log

PostPosted: Tue Jul 21, 2020 11:37 am
by matt (support)
You can set isError=True as an optional argument and it will show in red. There is an example here.

Re: Print text to Event Log

PostPosted: Thu Mar 11, 2021 10:08 am
by jltnol
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.