Re: [Sikuli-driver] [Question #658613]: issues when using Python logging module in sikuli

2017-09-26 Thread Manfred Hampl
Question #658613 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/658613

Manfred Hampl proposed the following answer:
I assume that your usage of the logging module is not correct.

As far as I know logger.addHandler() needs a handler as its parameter,
and not a file name.

Maybe you can use https://docs.python.org/2.3/lib/node304.html as a
template.

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


Re: [Sikuli-driver] [Question #658613]: issues when using Python logging module in sikuli

2017-09-25 Thread TestMechanic
Question #658613 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/658613

Status: Open => Answered

TestMechanic proposed the following answer:
Try to change

logger.setLevel(logging.DEBUG)

to

logger.setLevel(10)

See here - https://docs.python.org/2/library/logging.html#logging-levels

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp


[Sikuli-driver] [Question #658613]: issues when using Python logging module in sikuli

2017-09-24 Thread linmiaoling
New question #658613 on Sikuli:
https://answers.launchpad.net/sikuli/+question/658613

Hi all,
i have issues when using Python logging module in sikuli

run following script in sikuli ide :

import logging

# when run in IDE with reruns to avoid errors use
import logging; reload(logging)

#create a new logging instance
logger = logging.getLogger("MyLogger")

#set the file to log to
logger.addHandler(r"D:\\TestingReports\\file.log")

#set the logging level, DEBUG is the most verbose level
logger.setLevel(logging.DEBUG)

logger.info("We are starting now")

def functionInMyScript():
 logger.debug("entering functionInMyScript()")
 # do something that might fail
 print("run function success!!")
 logger.debug("leaving functionInMyScript()")

try:
functionInMyScript()
logger.debug("Function call succeeded")
except:
logger.error("Function call failed")


but i get error:
[error] script [ log_1 ] stopped with error in line 15
[error] AttributeError ( 'str' object has no attribute 'level' )
[error] --- Traceback --- error source first line: module ( function ) 
statement 1319: __init__ ( callHandlers ) if record.levelno >= hdlr.level:
1280: __init__ ( handle ) self.callHandlers(record)
1270: __init__ ( _log ) self.handle(record)
1151: __init__ ( info ) self._log(INFO, msg, args, **kwargs)
[error] --- Traceback --- end --


What should i do ?
thanks for the help!


-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

___
Mailing list: https://launchpad.net/~sikuli-driver
Post to : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp