Logging

This indipydriver package uses the Python standard library logging module, and emits logs at levels:

ERROR Logs errors including tracebacks from exceptions

WARNING Logs connection status for remote links

INFO Logs informational messages.

DEBUG Logs xml data transmitted and received.

By default, the set level is WARNING. If you want no logs, and you want nothing to be sent to the console, then at the top of your script insert:

import logging
logger = logging.getLogger()
logger.addHandler(logging.NullHandler())

Alternatively, if you want more logs to include INFO level data, printed to stdout then use:

import logging, sys
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler(sys.stdout)
logger.addHandler(handler)

If you would prefer to log to a file, at the top of your script include:

import logging
logger = logging.getLogger()
handler = logging.FileHandler("logfile.log")
logger.addHandler(handler)

To log the xml traffic add the further line:

logger.setLevel(logging.DEBUG)

You would also need to set debug_enable on your driver:

driver.debug_enable = True

This leaves you with the flexibility to add any available loghandler (see the Python logging documentation), and to set your own formats if required.

Advanced

The logging.getlogger() command shown above gets the root logger, which gathers all logs generated by all the Python modules in your package. However you can ‘get’ other loggers by specifying module paths, so:

driverlogger = logging.getlogger("indipydriver.ipydriver")

indipydriver.ipydriver - generates driver logs.

indipyserver.exdriver - generates executable driver logs.

indipyserver.remote - generates remote connection logs.

indipyserver.ipyserver - generates server connection logs.

You could then add file handlers and set logging levels to each logger separately.