def casalogger(logfile=''):
"""
Spawn a new casalogger using logfile as the filename.
You should only call this if the casalogger dies or you close it
and restart it again.
Note: if you changed the name of the log file using casalog.setlogfile
you will need to respawn casalogger with the new log filename. Eventually,
we will figure out how to signal the casalogger with the new name but not
for a while.
"""
if logfile == '':
if casa.has_key('files') and casa['files'].has_key('logfile') :
logfile = casa['files']['logfile']
else:
casa['files']['logfile'] = os.getcwd( ) + '/casa.log'
logfile = 'casa.log'
pid=9999
if (os.uname()[0]=='Darwin'):
if casa['helpers']['logger'] == 'console':
os.system("open -a console " + logfile)
else:
# XCode7 writes debug messages to stderr, which then end up in the
# Casa console. Hence the stderr is directed to devnull
#pid=os.spawnvp(os.P_NOWAIT,casa['helpers']['logger'],[casa['helpers']['logger'], logfile])
DEVNULL = open(os.devnull, 'w')
pid = Popen([casa['helpers']['logger'],logfile], stderr=DEVNULL).pid
#pid = Popen([casa['helpers']['logger'],logfile], stdin=PIPE, stdout=FNULL, stderr=STDOUT).pid
elif (os.uname()[0]=='Linux'):
pid=os.spawnlp(os.P_NOWAIT,casa['helpers']['logger'],casa['helpers']['logger'],logfile)
else:
print 'Unrecognized OS: No logger available'
if (pid!=9999): logpid.append(pid)
评论列表
文章目录