How to use Python to write an error to the log

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Sun Sep 30, 2012 12:26 am
bob offline
User avatar
Posts: 500
Joined: Jun 14, 2006

How to use Python to write an error to the log

How do you use Python to write to the log in the same manner you would Applescript? Can you make it red?

Like so;

Code: Select all
Script Error                    embedded script: invalid syntax


thanks,

bob

Posted on
Sun Sep 30, 2012 8:05 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: How to use Python to write an error to the log

bob wrote:
How do you use Python to write to the log in the same manner you would Applescript? Can you make it red?
Code: Select all
Script Error                    embedded script: invalid syntax



Bob, you didn't include your test script... So it's hard to see what is going wrong.... But....

indigo.server.log ("text to write to log", isError=True)

or

self.debugLog ("text to write to log", isError=True)

should work fine, depending on what your trying to do.

- Ben

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Sun Sep 30, 2012 10:29 am
bob offline
User avatar
Posts: 500
Joined: Jun 14, 2006

Re: How to use Python to write an error to the log

Ben,

Thanks for your reply. I have Python script that parses an xml file on my network. Sometimes it doesn't make the connection and I get a URLError. The error is written to the log but does not have "Script Error" title in the log. I want the script to write the error to the log as a Script Error. See my script and the error here;

viewtopic.php?f=18&t=8856

thanks for any help!

bob

Posted on
Sun Sep 30, 2012 2:53 pm
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: How to use Python to write an error to the log

bob wrote:
Ben,

Thanks for your reply. I have Python script that parses an xml file on my network. Sometimes it doesn't make the connection and I get a URLError. The error is written to the log but does not have "Script Error" title in the log. I want the script to write the error to the log as a Script Error. See my script and the error here;

viewtopic.php?f=18&t=8856


See the follow up in the other thread....

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Sun Sep 30, 2012 5:32 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: How to use Python to write an error to the log

bob wrote:
... The error is written to the log but does not have "Script Error" title in the log. I want the script to write the error to the log as a Script Error.


Use
Code: Select all
indigo.server.log("Text in log file", "Script", isError=True)


This will cause the error log type to show up as "Script Error" in your Indigo log. I'd recommend, however, using something more specific to the script returning the error, such as "XML Reader Script Error" rather than a generic "Script Error", so that you can track which script it is returning the error.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest