sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #27293
[Question #252333]: The run result repeat several times when import logging module.
New question #252333 on Sikuli:
https://answers.launchpad.net/sikuli/+question/252333
Hi Raiman,
I have a question about import logging under Sikuli environment. But this issue cannot be reproduced under python environment. please see my program as below, the run result will repeat several times but I just run one time. I think the expected result is one log.
Could you please give me the solution for this?
import logging
def TT(String):
logger = logging.getLogger('mylogger')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler('test.log')
fh.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(formatter)
ch.setFormatter(formatter)
logger.addHandler(fh)
logger.addHandler(ch)
logger.info(String)
if __name__ == "__main__":
TT('yes')
Run result:
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
2014-07-29 11:11:51,969 - mylogger - INFO - yes
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.