from extensions.rt_service import rt_service as rts
import logging
import threading
import time




def thread_function(name):

    logging.info("Thread %s: starting", name)
    rtserv = rts.RT_Service()
    isok = rtserv.initLogChannel()
    if (not isok):
        logging.info("Thread %s: could not open the logport", name)         

    while (isok):
            msg = rtserv.readLogChannel()
            logging.info(msg)
            if (msg == 'noResult'):
                 break
    
    logging.info("Thread %s: finishing", name)



def createCoproLoggingTask():
    format = "%(asctime)s: %(message)s"
    logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
    x = threading.Thread(target=thread_function, args=(1,))

    x.start()
    return x

