← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #180346]: Timestamp in logfile

 

Question #180346 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/180346

RaiMan posted a new comment:
@ Jason

There seems to be some conflict with Sikuli's own use of Python's
logging feature.

So you should use your own logging handler.

This is a basic template for messages going to a file:

import logging # once at beginning of script

# initialization
myHandler = logging.FileHandler('/Users/fitlab/SikuliLog/new.log')
myLog = logging.getLogger()
myLog.addHandler(myHandler)
myLog.setLevel(logging.DEBUG)

# usage
myLog.debug('This message should go to the log file')
myLog.info('So should this')
myLog.warning('And this, too')

# shutdown (a must in the IDE ! )
myHandler.close()

This worked as expected on my Mac Lion.

--- log file was not created ??
using
myHandler = logging.FileHandler('/Users/fitlab/SikuliLog/new.log')

the folder
/Users/fitlab/SikuliLog

has to be there (not auto created) before running the script.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.