The Speect Engine is initialized when the Speect module is imported (see Initialization for the details of the Speect Engine C initialization):
When using Speect from a built tree one must tell Python where to find the Speect Python bindings, see the installation documentation.
There is no finalization method for Speect as the destruction of modules and objects in modules is done in random order (in Python), which may cause destructors to fail when they depend on other objects (even functions) or modules.
- if Debug then logging will be written to the stderr stream, otherwise
- no logging will be done.
If the Speect Engine error handling mechanism is active (see Error handling and Debugging in Python), then a Python logger instance of the type logging.Logger can be given to Speect to log errors, warnings and debug messages to (speect.setLogger()). The Speect Engine debugging level is set to S_DBG_ALL and all logging events are passed on to the Python logger, which can filter the logging messages based on the level. The Speect s_log_event levels are converted to Python logging levels as in the table below:
The logger fills the logging info dictionary with the following key-value pairs:
|se_event||String value of the log event level (s_log_event_str())|
|se_function||Function name where error occurred or “unknown”|
|se_file||File name where error occurred or “unknown”|
|se_line||Line number where error occurred or “unknown”|
|se_user_msg||User message (message in context setting macros)|
An example Python logging configuration (see Python documentation on configuration file formats for the logging.fileConfig() method) is given in Python logging configuration example and can be used as follows:
import speect import logging import logging.config # read config file logging.config.fileConfig("spct_python_log.conf") # create the logger instance logger = logging.getLogger("SpeectEngine") # pass it to speect speect.setLogger(logger)