trace_header = '[_TRACE_]'
trace_num = 0
event_header = '[_EVENT_]'
timestamp = True

g_log_file = '/tmp/' + 'mmi.log'

def checkLogSize():
	import os
	global g_log_file 
	try:
		size=os.stat(g_log_file)[6]
		if size > (500*1024): # if logfile is larger than 500 K byte
			os.remove(g_log_file)
			os.system('sync')
			f = open(g_log_file, 'a+')
			f.write('*** LOGGING - RESTART ***\n')
			f.close()		
	except:
		pass
		
def debugLogC(format, *args):
	return True

def debugLogN(format, *args):
	return True

def debug_get_time():
	import time, ntptime
	lt = time.localtime(time.time())
	return '%02d:%02d:%02d' % (lt[3], lt[4], lt[5])

def roxia_get_time():
	import time, ntptime
	lt = time.localtime(ntptime.ntime())
	return '%02d:%02d:%02d' % (lt[3], lt[4], lt[5])

def roxia_trace(a1, *args):
	if __debug__:
		global timestamp
		if timestamp:
			header = trace_header + '(%s)' % roxia_get_time()
		else:
			header = trace_header
		print header, a1,
		for a in args:
			print a,
		print

def roxia_tracef(format, *args):
	if __debug__:
		global timestamp
		if timestamp:
			header = trace_header + '(%s)' % roxia_get_time()
		else:
			header
		print header + ' ' + format % args

