Skip to main content

Overview

The OpenShift Python Wrapper includes comprehensive logging capabilities to help you debug issues and monitor resource operations. You can control log verbosity and configure sensitive data handling.

Log Levels

The wrapper supports standard Python logging levels:
  • DEBUG: Detailed information for diagnosing problems
  • INFO: Confirmation that things are working as expected (default)
  • WARNING: Indication that something unexpected happened
  • ERROR: A serious problem occurred
  • CRITICAL: A very serious error occurred

Setting Log Level

Using Environment Variable

The recommended way to set the log level is via environment variable:
The log level must be set before importing the wrapper modules. Changes to the environment variable after import will not take effect.

Setting at Runtime

You can also configure logging programmatically:

Log Output Examples

INFO Level (Default)

At INFO level, you’ll see high-level operations:
Output:

DEBUG Level

At DEBUG level, you’ll see detailed operation information:
Output:
DEBUG level generates extensive output. Only use it for troubleshooting specific issues.

Command Execution Logging

When executing commands in pods, the wrapper logs execution details:
With INFO level:
With DEBUG level:

Sensitive Data Handling

By default, the wrapper hashes sensitive information in logs for security:
Default output (hashed):

Disable Log Hashing

In secure environments (like local development), you can disable hashing:
Only disable log hashing in secure, controlled environments. Never disable it in production or shared environments where logs might be exposed.
With hashing disabled:

Custom Logger Configuration

Configure Logger Per Module

Configure logging for specific modules:

Custom Log Format

Customize the log output format:
Output:

Log to File

Direct logs to a file instead of console:

Log to Both File and Console

Troubleshooting with Logs

Debugging Resource Creation Issues

Debugging Command Execution

Debugging Wait Operations

Configuration Best Practices

  1. Use INFO for Production: Keep default INFO level in production
  2. DEBUG for Development: Use DEBUG only when troubleshooting
  3. Secure Sensitive Data: Keep log hashing enabled in shared environments
  4. Log to Files: Use file logging for long-running operations
  5. Rotate Logs: Implement log rotation for production systems
  6. Filter Noise: Configure specific modules to reduce log volume
  7. Monitor Log Size: Watch log file sizes when DEBUG is enabled

Environment Variables Summary