← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #165999]: Logging and reporting in project Sikuli

 

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

Harry Readinger posted a new comment:
The python logging class is very easy to set up and I recommend using
that for logging.

information on python logging is here:
http://docs.python.org/library/logging.html

here is a quick, basic example of using logging:

import logging

#create a new logging instance
logger = logging.getLogger("MyLogger")
#set the file to log to
logger.fileHandler("C:\path\to\your\log\file.log")
#set the logging level, DEBUG is the most verbose level
logger.setLevel(logging.DEBUG)

<script you want to run>

try:
    functionInMyScript()
    logger.debug("This is a debug log message")
except
    logger.error("this is an error message in your log")

___________________________________________________

You can also set up filters and log to different files depending on the log level. 
Because logger uses handlers, you can do all this with a single logging instance.

It is a very flexible logging solution

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