ccproxy.core.logging¶
ccproxy.core.logging
¶
TraceBoundLogger
¶
TraceBoundLoggerImpl
¶
CategoryConsoleRenderer
¶
trace
¶
category_filter
¶
Filter logs by category based on environment configuration.
Source code in ccproxy/core/logging.py
format_category_for_console
¶
Format category field for better visibility in console output.
Source code in ccproxy/core/logging.py
configure_structlog
¶
configure_structlog(log_level=INFO)
Configure structlog with shared processors following canonical pattern.
Source code in ccproxy/core/logging.py
rich_traceback
¶
Pretty-print exc_info to sio using the Rich package.
Source code in ccproxy/core/logging.py
setup_logging
¶
Setup logging for the entire application using canonical structlog pattern. Returns a structlog logger instance.
Source code in ccproxy/core/logging.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | |
get_logger
¶
Get a structlog logger instance with request context automatically bound.
This function checks for an active RequestContext and automatically binds the request_id to the logger if available, ensuring all logs are correlated with the current request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Logger name (typically name) |
None
|
Returns:
| Type | Description |
|---|---|
TraceBoundLogger
|
TraceBoundLogger with request_id bound if available |
Source code in ccproxy/core/logging.py
get_plugin_logger
¶
Get a plugin-aware logger with plugin_name automatically bound.
This function auto-detects the plugin name from the caller's module path and binds it to the logger. Preserves all existing functionality including request_id binding and trace method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Logger name (auto-detected from caller if None) |
None
|
Returns:
| Type | Description |
|---|---|
TraceBoundLogger
|
TraceBoundLogger with plugin_name and request_id bound if available |
Source code in ccproxy/core/logging.py
bootstrap_cli_logging
¶
Best-effort early logging setup from env and CLI args.
- Parses
--log-leveland--log-filefrom argv (if provided). - Honors env overrides
LOGGING__LEVEL,LOGGING__FILE. - Enables JSON logs if explicitly requested via
LOGGING__FORMAT=jsonorCCPROXY_JSON_LOGS=true. - No-op if structlog is already configured, letting later setup prevail.
This is intentionally lightweight and is followed by a full setup_logging
call after settings are loaded (e.g., in the serve command), so runtime
changes from config are still applied.
Source code in ccproxy/core/logging.py
set_command_context
¶
Bind a command-wide correlation ID to structlog context.
Uses structlog.contextvars so all logs (including from plugins) will carry
cmd_id once logging is configured with merge_contextvars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd_id
|
str | None
|
Optional explicit command ID. If None, a UUID4 is generated. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The command ID that was bound. |