관리 메뉴

caLAB

error Log txt파일 만들기 본문

TouchDesigner/TouchDesigner 코드

error Log txt파일 만들기

도이(doi) 2021. 6. 9. 16:15
728x90

error2_callbacks : error + warning 메시지 선별하는 코드 

import time

def onError(dat, rowIndex, message, absFrame, frame, severity, type, source):


	if severity == 2:
		s = str('warning')
		op('errorMsg').replaceCol(0, str(source))
		op('errorMsg').replaceCol(1, str(message))
		op('errorMsg').replaceCol(2, s)

	if severity == 3:
		s = str('error')
		op('errorMsg').replaceCol(0, str(source))
		op('errorMsg').replaceCol(1, str(message))
		op('errorMsg').replaceCol(2, s)

	return

datexec1(DAT execute) : 값이 바뀔 때만 file out으로 텍스트 파일 업데이트 

import time

def onTableChange(dat):
	t = time.localtime()
	current_time = time.strftime("%H:%M:%S", t)

	log = op('logTxt')
	em = op('errorMsg')
	fo = op('fileout1')

	log.clear()
	log.write(str('\n<<========== ') +str(current_time) + str(' ==========>>') +
		  str('\nseverity: ') + str(em[0,2]) +
		  str('\nsource: ') + str(em[0,0]) +
		  str('\nmessage: ') + str(em[0,1]))

	print(str('\n<<========== ') +str(current_time) + str(' ==========>>') +
		  str('\nseverity: ') + str(em[0,2]) +
		  str('\nsource: ') + str(em[0,0]) +
		  str('\nmessage: ') + str(em[0,1]))

	fo.par.write.pulse()

	return

def onRowChange(dat, rows):
	return

def onColChange(dat, cols):
	return

def onCellChange(dat, cells, prev):
	return

def onSizeChange(dat):
	return

 

728x90
반응형
Comments