← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #248604]: Sikuli logging into file

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
@ comment #2

-- callback option

something like this:

# your log function
def log(msg):
    global logfile
    try:
        logfile
    except:
        # print "setting logfile"
        logfile = open("SikuliLog.txt", "w")
    print >> logfile, msg

# the function, SikuliX should call instead of printing or writing to log file
def sikuliLog(msg):
    # one might evaluate and adapt msg here
    # or even do some filtering
    log(msg)

setSikuliXLogCallback(sikuliLog) # tell SikuliX to use the callback

log("starting")
find(something).highlight(2) 
log("finishing")

this would produce a log file content:
starting
[log] highlight message …
finishing

sikuliLog is the same as the functions used with onAppear, … (there it
is named handler in the docs, but it is a callback function)

hope it is clear now ;-)

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