ccproxy.docker.middleware¶
ccproxy.docker.middleware
¶
Docker output middleware for processing and logging container output.
LoggerOutputMiddleware
¶
Bases: OutputMiddleware[str]
Simple middleware that prints output with optional prefixes.
This middleware prints each line to the console with configurable prefixes for stdout and stderr streams.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stdout_prefix
|
str
|
Prefix for stdout lines (default: "") |
''
|
stderr_prefix
|
str
|
Prefix for stderr lines (default: "") |
''
|
Source code in ccproxy/docker/middleware.py
process
async
¶
Process and print a line with the appropriate prefix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line
|
str
|
Output line to process |
required |
stream_type
|
str
|
Either "stdout" or "stderr" |
required |
Returns:
Type | Description |
---|---|
str
|
The original line (unmodified) |
Source code in ccproxy/docker/middleware.py
create_logger_middleware
¶
Factory function to create a LoggerOutputMiddleware instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger_instance
|
Any | None
|
Logger instance to use (defaults to module logger) |
None
|
stdout_prefix
|
str
|
Prefix for stdout lines |
''
|
stderr_prefix
|
str
|
Prefix for stderr lines |
''
|
Returns:
Type | Description |
---|---|
LoggerOutputMiddleware
|
Configured LoggerOutputMiddleware instance |
Source code in ccproxy/docker/middleware.py
create_chained_docker_middleware
¶
create_chained_docker_middleware(
middleware_chain,
include_logger=True,
logger_instance=None,
stdout_prefix="",
stderr_prefix="",
)
Factory function to create chained middleware for Docker operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
middleware_chain
|
list[OutputMiddleware[Any]]
|
List of middleware components to chain together |
required |
include_logger
|
bool
|
Whether to automatically add logger middleware at the end |
True
|
logger_instance
|
Any | None
|
Logger instance to use (defaults to module logger) |
None
|
stdout_prefix
|
str
|
Prefix for stdout lines in logger middleware |
''
|
stderr_prefix
|
str
|
Prefix for stderr lines in logger middleware |
''
|
Returns:
Type | Description |
---|---|
OutputMiddleware[Any]
|
Chained middleware instance |