Deterred but not broken...
Use case: I want my own logger, so I can review the day's activity
1) I added a script in the directory /Library/Python/2.7/site-packages
- Code: Select all
"""
myLog.py
"""
try:
import logging
except ImportError:
print "Error importing logging"
raise ImportError
try:
import indigo
except ImportError:
print "The indigo module can only be used by scripts started from within Indigo"
raise ImportError
def log(input):
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('/Users/MYNAME/indigo/myLogger/myapp.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s', "%m-%d-%Y %H:%M:%S")
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
logger.error(input)
I call it from a script window in an Action Group like so:
- Code: Select all
import myLog
myLog.log("c")
Each successive run appears to open an additional handler or logger! If I log 'a', 'b', 'c' in successive runs, it spits out like so:
- Code: Select all
11-05-2018 21:50:56 ERROR a
11-05-2018 21:51:02 ERROR b
11-05-2018 21:51:02 ERROR b
11-05-2018 21:51:07 ERROR c
11-05-2018 21:51:07 ERROR c
11-05-2018 21:51:07 ERROR c
Any thoughts on how I check to see if a logger is already open, or something like that?
Thank you!