Logging
InterSystems IRIS Interoperability framework implements its own logging system. The Python API provides a way to use Python's logging module integrated with IRIS logging.
Basic Usage
The logging system is available through the component base class. You can access it via the logger
property or use the convenience methods:
def on_init(self):
# Using convenience methods
self.log_info("Component initialized")
self.log_error("An error occurred")
self.log_warning("Warning message")
self.log_alert("Critical alert")
self.trace("Debug trace message")
# Using logger property
self.logger.info("Info via logger")
self.logger.error("Error via logger")
Console Logging
You can direct logs to the console instead of IRIS in two ways:
- Set the component-wide setting:
def on_init(self):
self.log_to_console = True
self.log_info("This will go to console")
- Per-message console logging:
def on_message(self, request):
# Log specific message to console
self.log_info("Debug info", to_console=True)
# Other logs still go to IRIS
self.log_info("Production info")
Log Levels
The following log levels are available:
trace()
- Debug level logging (maps to IRIS LogTrace)log_info()
- Information messages (maps to IRIS LogInfo)log_warning()
- Warning messages (maps to IRIS LogWarning)log_error()
- Error messages (maps to IRIS LogError)log_alert()
- Critical/Alert messages (maps to IRIS LogAlert)log_assert()
- Assert messages (maps to IRIS LogAssert)
Integration with IRIS
The Python logging is automatically mapped to the appropriate IRIS logging methods:
- Python
DEBUG
→ IRISLogTrace
- Python
INFO
→ IRISLogInfo
- Python
WARNING
→ IRISLogWarning
- Python
ERROR
→ IRISLogError
- Python
CRITICAL
→ IRISLogAlert
Legacy Methods
The following methods are deprecated but maintained for backwards compatibility:
LOGINFO()
- Uselog_info()
insteadLOGALERT()
- Uselog_alert()
insteadLOGWARNING()
- Uselog_warning()
insteadLOGERROR()
- Uselog_error()
insteadLOGASSERT()
- Uselog_assert()
instead