bitranox-template-py-cli 2.1.3__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/CHANGELOG.md +30 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/PKG-INFO +2 -2
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/docs/systemdesign/module_reference.md +26 -29
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/pyproject.toml +3 -2
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/__init__conf__.py +1 -1
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/config.py +4 -4
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/email/_common.py +4 -8
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/email/send_email.py +5 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/email/send_notification.py +0 -2
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/config_load.py +12 -12
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/logging/setup.py +46 -22
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/memory/__init__.py +4 -4
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/memory/logging.py +7 -6
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/application/ports.py +5 -5
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/composition/__init__.py +8 -8
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/conftest.py +24 -12
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_config.py +22 -1
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_email.py +39 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_env_file.py +1 -1
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_deploy_permissions.py +1 -1
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_email_password_secrecy.py +2 -5
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_logging_dotenv_isolation.py +42 -6
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_permission_defaults.py +1 -3
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_ports.py +8 -8
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.devcontainer/devcontainer.json +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.devcontainer/settings.json +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.env.example +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.gitattributes +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.github/actions/extract-metadata/action.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.github/dependabot.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.github/workflows/codeql.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.github/workflows/default_cicd_public.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.github/workflows/default_release_public.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.gitignore +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.qlty/qlty.toml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/.snyk +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/CONFIG.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/CONTRIBUTING.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/DEVELOPMENT.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/INSTALL.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/LICENSE +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/Makefile +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/README.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/SECURITY.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/ai-stance.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/ai-transparency.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/codecov.yml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/docs/adr/0001-memory-adapters-in-src.md +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/notebooks/Quickstart.ipynb +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/rename.sh +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/rename_dry.sh +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/reset_git_history.sh +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/__main__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/email/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/info.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/commands/logging.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/constants.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/context.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/exit_codes.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/main.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/root.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/safe_console.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/cli/typed_click.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/defaultconfig.d/40-layered-config.toml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/defaultconfig.d/50-mail.toml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/defaultconfig.d/90-logging.toml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/defaultconfig.toml +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/deploy.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/display.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/loader.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/overrides.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/config/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/config.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/sender.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/transport.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/email/validation.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/logging/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/logging/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/memory/config.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/memory/email.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/adapters/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/application/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/application/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/composition/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/domain/__init__.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/domain/behaviors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/domain/enums.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/domain/errors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/domain/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/entry.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/src/bitranox_template_py_cli/py.typed +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_behaviors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cache_effectiveness.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_attachment_refused.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_config_errors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_core.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_email_config_errors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_exit_codes.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_main_exit.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_overrides.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_cli_validation.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_config_overrides.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_declared_dependencies.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_deploy_mode_safety.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_display.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_email_attachment_lists.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_email_config_translation.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_email_shipped_defaults.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_enums.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_errors.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_logging.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_mail.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_memory_logging.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_metadata.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_metadata_sync.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_module_entry.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_module_reference_sync.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_property_email.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_property_overrides.py +0 -0
- {bitranox_template_py_cli-2.1.3 → bitranox_template_py_cli-2.3.0}/tests/test_safe_console.py +0 -0
|
@@ -6,6 +6,36 @@ the [Keep a Changelog](https://keepachangelog.com/) format.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [2.3.0] 2026-10-08 16:14:12
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- **`config --profile NAME` checks the profile's logging settings instead of restarting logging.**
|
|
13
|
+
The check now runs through lib_log_rich's `validate_config`, which refuses exactly what starting
|
|
14
|
+
logging refuses, with the same `Error:` lines and exit 78, so nothing changes for an invalid
|
|
15
|
+
setting. What changes: the running logging runtime is no longer shut down and started again, so
|
|
16
|
+
the rest of the command keeps logging with the settings logging started with (not the profile's),
|
|
17
|
+
and a `main()` call from a worker thread no longer replaces the logging every other thread uses.
|
|
18
|
+
The `RestartLogging` port is now `CheckLoggingConfig` (`AppServices.check_logging_config`; the
|
|
19
|
+
testing composition's double refuses nothing). Requires `lib_log_rich>=6.4.2`.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
- **A logging refusal no single setting owns reads `lib_log_rich: <reason>`.** Such a problem (for
|
|
23
|
+
example TLS together with UDP for Graylog, which lib_log_rich 6.4.2 now refuses up front) has no
|
|
24
|
+
key, and its `Error:` line came out as `lib_log_rich.: <reason>` with a dangling dot.
|
|
25
|
+
|
|
26
|
+
## [2.2.0] 2026-10-08 13:56:49
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
- **`send-notification --raise-on-missing-attachments` (usage change).** A notification takes no
|
|
30
|
+
attachments, so the switch did nothing there. `send-notification` now refuses it as an unknown
|
|
31
|
+
option (exit 2); `send-email` keeps it. Drop the flag from any script that passes it to
|
|
32
|
+
`send-notification`.
|
|
33
|
+
|
|
34
|
+
### Tests
|
|
35
|
+
- The `config-deploy --force` report for a deploy in which every target file is already identical
|
|
36
|
+
is covered end to end. New shared fixture `user_layer_in_tmp_path` points every OS's user-layer
|
|
37
|
+
location at `tmp_path`; it replaces two hand-written copies of the same loop.
|
|
38
|
+
|
|
9
39
|
## [2.1.3] 2026-10-08 11:57:40
|
|
10
40
|
|
|
11
41
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bitranox_template_py_cli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Template CLI application with configuration management and structured logging
|
|
5
5
|
Project-URL: Homepage, https://github.com/bitranox/bitranox_template_py_cli
|
|
6
6
|
Project-URL: Repository, https://github.com/bitranox/bitranox_template_py_cli.git
|
|
@@ -25,7 +25,7 @@ Requires-Dist: btx-lib-mail>=4.0.0
|
|
|
25
25
|
Requires-Dist: click>=8.5.0
|
|
26
26
|
Requires-Dist: lib-cli-exit-tools>=2.4.0
|
|
27
27
|
Requires-Dist: lib-layered-config>=7.0.1
|
|
28
|
-
Requires-Dist: lib-log-rich>=6.
|
|
28
|
+
Requires-Dist: lib-log-rich>=6.4.2
|
|
29
29
|
Requires-Dist: orjson>=3.13.0
|
|
30
30
|
Requires-Dist: pydantic>=2.13.5
|
|
31
31
|
Requires-Dist: python-dotenv>=1.2.4
|
|
@@ -26,14 +26,14 @@ moves or removes a module, a CLI option or a public name.
|
|
|
26
26
|
- `src/bitranox_template_py_cli/adapters/email/transport.py` - `send_email` / `send_notification` over btx_lib_mail
|
|
27
27
|
- `src/bitranox_template_py_cli/adapters/email/sender.py` - Re-exports of `config.py` and `transport.py`
|
|
28
28
|
- `src/bitranox_template_py_cli/adapters/email/validation.py` - Email recipient validation
|
|
29
|
-
- `src/bitranox_template_py_cli/adapters/logging/setup.py` - lib_log_rich initialization; takes only the `LOG_*` lines of a `.env`, and raises `InvalidLoggingConfigError` for a refused `[lib_log_rich]` value or `LOG_*` variable, after starting logging with its defaults (and without the `LOG_*` variables only when one of them is refused); `
|
|
29
|
+
- `src/bitranox_template_py_cli/adapters/logging/setup.py` - lib_log_rich initialization; takes only the `LOG_*` lines of a `.env`, and raises `InvalidLoggingConfigError` for a refused `[lib_log_rich]` value or `LOG_*` variable, after starting logging with its defaults (and without the `LOG_*` variables only when one of them is refused); `check_logging_config` refuses another configuration's logging settings through lib_log_rich's `validate_config`, without touching the running runtime
|
|
30
30
|
- `src/bitranox_template_py_cli/adapters/cli/` - CLI adapter package:
|
|
31
31
|
- `__init__.py` - Public facade
|
|
32
32
|
- `constants.py` - Shared constants
|
|
33
33
|
- `safe_console.py` - Encode-safe terminal output; use `safe_console.echo` instead of `click.echo`
|
|
34
34
|
- `exit_codes.py` - POSIX exit codes (ExitCode IntEnum)
|
|
35
35
|
- `context.py` - Click context helpers
|
|
36
|
-
- `config_load.py` - Configuration load for the CLI; records a load failure, `require_config` refuses with exit 78, `
|
|
36
|
+
- `config_load.py` - Configuration load for the CLI; records a load failure, `require_config` refuses with exit 78, `check_logging` checks the logging settings of a configuration reloaded by `config --profile`, refusing them as the root does
|
|
37
37
|
- `root.py` - Root command group
|
|
38
38
|
- `main.py` - Entry point
|
|
39
39
|
- `typed_click.py` - Strictly typed wrappers for rich_click's `option`, `version_option` and `get_current_context`
|
|
@@ -251,22 +251,18 @@ Send email using configured SMTP settings.
|
|
|
251
251
|
|
|
252
252
|
Send simple plain-text notification email.
|
|
253
253
|
|
|
254
|
-
| Option
|
|
255
|
-
|
|
256
|
-
| `--to ADDRESS`
|
|
257
|
-
| `--subject TEXT`
|
|
258
|
-
| `--message TEXT`
|
|
259
|
-
| `--from ADDRESS`
|
|
260
|
-
| `--smtp-host HOST:PORT`
|
|
261
|
-
| `--smtp-username USER`
|
|
262
|
-
| `--smtp-password PASS`
|
|
263
|
-
| `--use-starttls / --no-use-starttls`
|
|
264
|
-
| `--timeout SECONDS`
|
|
265
|
-
| `--raise-on-
|
|
266
|
-
| `--raise-on-invalid-recipient / --no-raise-on-invalid-recipient` | Override invalid-recipient handling |
|
|
267
|
-
|
|
268
|
-
`--raise-on-missing-attachments` is accepted for symmetry with `send-email`, but a notification
|
|
269
|
-
carries no attachments, so it has no effect.
|
|
254
|
+
| Option | Description |
|
|
255
|
+
|------------------------------------------------------------------|-------------------------------------|
|
|
256
|
+
| `--to ADDRESS` | Recipient (repeatable) |
|
|
257
|
+
| `--subject TEXT` | Subject - required |
|
|
258
|
+
| `--message TEXT` | Message - required |
|
|
259
|
+
| `--from ADDRESS` | Override sender |
|
|
260
|
+
| `--smtp-host HOST:PORT` | Override SMTP host (repeatable) |
|
|
261
|
+
| `--smtp-username USER` | Override username |
|
|
262
|
+
| `--smtp-password PASS` | Override password |
|
|
263
|
+
| `--use-starttls / --no-use-starttls` | Override STARTTLS |
|
|
264
|
+
| `--timeout SECONDS` | Override timeout |
|
|
265
|
+
| `--raise-on-invalid-recipient / --no-raise-on-invalid-recipient` | Override invalid-recipient handling |
|
|
270
266
|
|
|
271
267
|
**Exit codes:** 0, 2 (usage error), 22 (invalid option value), 69 (SMTP failure), 78 (no SMTP hosts, an invalid `[email]` section, or configuration not loadable)
|
|
272
268
|
|
|
@@ -413,7 +409,7 @@ The `adapters/memory/` package provides lightweight implementations for testing:
|
|
|
413
409
|
|---------------------|-----------------------------------------------------------------------------|
|
|
414
410
|
| `memory/config.py` | `GetConfig`, `GetDefaultConfigPath`, `DeployConfiguration`, `DisplayConfig` |
|
|
415
411
|
| `memory/email.py` | `SendEmail`, `SendNotification` |
|
|
416
|
-
| `memory/logging.py` | `InitLogging`, `
|
|
412
|
+
| `memory/logging.py` | `InitLogging`, `CheckLoggingConfig` |
|
|
417
413
|
|
|
418
414
|
`adapters/memory` exports `EmailSpy` (from `memory/email.py`): its `send_email` and
|
|
419
415
|
`send_notification` methods satisfy the email ports and record each call as a `CapturedEmail` /
|
|
@@ -425,16 +421,17 @@ Use `composition.build_testing()` to wire all in-memory adapters. It wires the r
|
|
|
425
421
|
|
|
426
422
|
### Test Fixtures (conftest.py)
|
|
427
423
|
|
|
428
|
-
| Fixture | Purpose
|
|
429
|
-
|
|
430
|
-
| `config_factory` | Creates real `Config` instances from test data
|
|
431
|
-
| `inject_config` | Injects config into CLI path
|
|
432
|
-
| `cli_runner` | Fresh `CliRunner` per test
|
|
433
|
-
| `strip_ansi` | Strips ANSI escape codes from output
|
|
434
|
-
| `clear_config_cache` | Clears LRU cache before tests
|
|
435
|
-
| `managed_traceback_state` | Resets/restores traceback configuration
|
|
436
|
-
| `isolated_logging_state` | Autouse: after every test, shuts the lib_log_rich runtime down and restores the root logger; yields that restore step
|
|
424
|
+
| Fixture | Purpose |
|
|
425
|
+
|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
426
|
+
| `config_factory` | Creates real `Config` instances from test data |
|
|
427
|
+
| `inject_config` | Injects config into CLI path |
|
|
428
|
+
| `cli_runner` | Fresh `CliRunner` per test |
|
|
429
|
+
| `strip_ansi` | Strips ANSI escape codes from output |
|
|
430
|
+
| `clear_config_cache` | Clears LRU cache before tests |
|
|
431
|
+
| `managed_traceback_state` | Resets/restores traceback configuration |
|
|
432
|
+
| `isolated_logging_state` | Autouse: after every test, shuts the lib_log_rich runtime down and restores the root logger; yields that restore step |
|
|
433
|
+
| `user_layer_in_tmp_path` | Points every OS's user-layer location (`HOME`, `USERPROFILE`, `XDG_CONFIG_HOME`, `APPDATA`, `LOCALAPPDATA`) at `tmp_path` and returns it, so a real deploy writes there |
|
|
437
434
|
|
|
438
435
|
---
|
|
439
436
|
|
|
440
|
-
**Last Updated:** 2026-10-
|
|
437
|
+
**Last Updated:** 2026-10-08 (`send-notification` options, test fixtures)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "bitranox_template_py_cli"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.3.0"
|
|
4
4
|
description = "Template CLI application with configuration management and structured logging"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -9,7 +9,8 @@ dependencies = [
|
|
|
9
9
|
# Imported directly (adapters/cli/main.py, commands/config.py), not only through rich-click.
|
|
10
10
|
"click>=8.5.0",
|
|
11
11
|
"lib_cli_exit_tools>=2.4.0",
|
|
12
|
-
|
|
12
|
+
# 6.4.2: validate_config, the check config --profile runs, refuses exactly what init() refuses.
|
|
13
|
+
"lib_log_rich>=6.4.2",
|
|
13
14
|
"python-dotenv>=1.2.4",
|
|
14
15
|
"lib_layered_config>=7.0.1",
|
|
15
16
|
"btx_lib_mail>=4.0.0",
|
|
@@ -40,7 +40,7 @@ name = "bitranox_template_py_cli"
|
|
|
40
40
|
#: Human-readable summary shown in CLI help output.
|
|
41
41
|
title = "Template CLI application with configuration management and structured logging"
|
|
42
42
|
#: Current release version pulled from ``pyproject.toml`` by automation.
|
|
43
|
-
version = "2.
|
|
43
|
+
version = "2.3.0"
|
|
44
44
|
#: Repository homepage presented to users.
|
|
45
45
|
homepage = "https://github.com/bitranox/bitranox_template_py_cli"
|
|
46
46
|
#: Author attribution surfaced in CLI output.
|
|
@@ -32,7 +32,7 @@ from bitranox_template_py_cli.adapters.config.overrides import nest_overrides
|
|
|
32
32
|
from bitranox_template_py_cli.domain.enums import DeployTarget, OutputFormat
|
|
33
33
|
|
|
34
34
|
from .. import safe_console
|
|
35
|
-
from ..config_load import load_config, report_load_failure, require_config
|
|
35
|
+
from ..config_load import check_logging, load_config, report_load_failure, require_config
|
|
36
36
|
from ..constants import CLICK_CONTEXT_SETTINGS
|
|
37
37
|
from ..context import CLIContext, get_cli_context
|
|
38
38
|
from ..exit_codes import ExitCode
|
|
@@ -110,8 +110,8 @@ def _resolve_config(ctx: click.Context, cli_ctx: CLIContext, profile: str | None
|
|
|
110
110
|
|
|
111
111
|
When a subcommand-level profile override is specified, reloads config
|
|
112
112
|
with that profile, the root's ``--env-file`` and any root-level ``--set``
|
|
113
|
-
overrides stored in the CLI context, and
|
|
114
|
-
|
|
113
|
+
overrides stored in the CLI context, and checks its logging settings, which
|
|
114
|
+
are refused the way the root refuses its own; logging itself keeps running unchanged.
|
|
115
115
|
|
|
116
116
|
Args:
|
|
117
117
|
ctx: The running command's click context, exited with 78 when loading failed.
|
|
@@ -128,7 +128,7 @@ def _resolve_config(ctx: click.Context, cli_ctx: CLIContext, profile: str | None
|
|
|
128
128
|
cli_ctx.services, profile=profile, env_file=cli_ctx.env_file, set_overrides=cli_ctx.set_overrides
|
|
129
129
|
)
|
|
130
130
|
if error is None:
|
|
131
|
-
error =
|
|
131
|
+
error = check_logging(cli_ctx.services, config)
|
|
132
132
|
if error is not None:
|
|
133
133
|
report_load_failure(error, show_traceback=cli_ctx.traceback)
|
|
134
134
|
ctx.exit(ExitCode.CONFIG_ERROR)
|
|
@@ -84,9 +84,10 @@ def smtp_config_options(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
84
84
|
"""Apply shared SMTP configuration override options to a Click command.
|
|
85
85
|
|
|
86
86
|
Adds CLI flags for the SMTP connection and delivery settings (hosts, credentials,
|
|
87
|
-
STARTTLS, timeout,
|
|
88
|
-
``
|
|
89
|
-
|
|
87
|
+
STARTTLS, timeout, ``raise_on_invalid_recipient``). ``send-email`` adds its own
|
|
88
|
+
``--raise-on-missing-attachments`` switch, since only it takes attachments.
|
|
89
|
+
``starttls_verify``, ``local_hostname``, ``delivery_deadline``, ``recipient_max_count``
|
|
90
|
+
and the attachment settings have no flag; set them with ``--set email.<key>=...``.
|
|
90
91
|
"""
|
|
91
92
|
options = [
|
|
92
93
|
option(
|
|
@@ -100,11 +101,6 @@ def smtp_config_options(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
100
101
|
option("--smtp-password", default=None, help="Override SMTP authentication password"),
|
|
101
102
|
option("--use-starttls/--no-use-starttls", default=None, help="Override STARTTLS setting"),
|
|
102
103
|
option("--timeout", "timeout", type=float, default=None, help="Override socket timeout in seconds"),
|
|
103
|
-
option(
|
|
104
|
-
"--raise-on-missing-attachments/--no-raise-on-missing-attachments",
|
|
105
|
-
default=None,
|
|
106
|
-
help="Override missing attachment handling",
|
|
107
|
-
),
|
|
108
104
|
option(
|
|
109
105
|
"--raise-on-invalid-recipient/--no-raise-on-invalid-recipient",
|
|
110
106
|
default=None,
|
|
@@ -73,6 +73,11 @@ def _log_send_email_start(
|
|
|
73
73
|
type=click.Path(path_type=str),
|
|
74
74
|
help="File to attach (can specify multiple)",
|
|
75
75
|
)
|
|
76
|
+
@option(
|
|
77
|
+
"--raise-on-missing-attachments/--no-raise-on-missing-attachments",
|
|
78
|
+
default=None,
|
|
79
|
+
help="Override missing attachment handling",
|
|
80
|
+
)
|
|
76
81
|
@smtp_config_options
|
|
77
82
|
@click.pass_context
|
|
78
83
|
def cli_send_email(
|
|
@@ -53,7 +53,6 @@ def cli_send_notification(
|
|
|
53
53
|
smtp_password: str | None,
|
|
54
54
|
use_starttls: bool | None,
|
|
55
55
|
timeout: float | None,
|
|
56
|
-
raise_on_missing_attachments: bool | None,
|
|
57
56
|
raise_on_invalid_recipient: bool | None,
|
|
58
57
|
) -> None:
|
|
59
58
|
"""Send a simple plain-text notification email.
|
|
@@ -77,7 +76,6 @@ def cli_send_notification(
|
|
|
77
76
|
smtp_password=smtp_password,
|
|
78
77
|
smtp_use_starttls=use_starttls,
|
|
79
78
|
smtp_timeout=timeout,
|
|
80
|
-
raise_on_missing_attachments=raise_on_missing_attachments,
|
|
81
79
|
raise_on_invalid_recipient=raise_on_invalid_recipient,
|
|
82
80
|
)
|
|
83
81
|
try:
|
|
@@ -16,7 +16,7 @@ Contents:
|
|
|
16
16
|
* :func:`load_config` - load with profile, ``.env`` and ``--set``, or say why not.
|
|
17
17
|
* :func:`start_logging` - start logging; an invalid ``[lib_log_rich]`` value or ``LOG_*``
|
|
18
18
|
variable is a load failure.
|
|
19
|
-
* :func:`
|
|
19
|
+
* :func:`check_logging` - the same refusal for a configuration loaded after logging started.
|
|
20
20
|
* :func:`require_config` - the configuration, or exit 78 naming the failure.
|
|
21
21
|
* :func:`report_load_failure` - the one-line report, after the traceback on request.
|
|
22
22
|
* :func:`echo_load_traceback` - the loader's traceback alone, for a caller with its own line.
|
|
@@ -105,7 +105,8 @@ def start_logging(
|
|
|
105
105
|
refused setting) before it raises, and the commands that read the configuration refuse with
|
|
106
106
|
exit 78 and the refusal: ``lib_log_rich.<key>: <reason>`` for a problem the section's type
|
|
107
107
|
check finds, lib_log_rich's own message for a value only lib_log_rich refuses, whether it
|
|
108
|
-
came from the section or a ``LOG_*`` variable (``lib_log_rich:
|
|
108
|
+
came from the section or a ``LOG_*`` variable (``lib_log_rich: Invalid runtime settings:
|
|
109
|
+
console_level: Unknown log level: 'bogus'``).
|
|
109
110
|
|
|
110
111
|
Args:
|
|
111
112
|
services: The composition's services; only ``init_logging`` is used.
|
|
@@ -124,25 +125,24 @@ def start_logging(
|
|
|
124
125
|
return config, config_error
|
|
125
126
|
|
|
126
127
|
|
|
127
|
-
def
|
|
128
|
-
"""
|
|
128
|
+
def check_logging(services: AppServices, config: Config) -> Exception | None:
|
|
129
|
+
"""Judge the logging settings of a configuration loaded after logging started; a refusal is returned.
|
|
129
130
|
|
|
130
131
|
``config --profile`` reloads the configuration once logging is running, so
|
|
131
132
|
:func:`start_logging` never sees the reloaded ``[lib_log_rich]`` section; without this an
|
|
132
|
-
invalid value there would display with exit 0 while plain ``config`` exits 78.
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
invalid value there would display with exit 0 while plain ``config`` exits 78. The check
|
|
134
|
+
refuses what :func:`start_logging` refuses, in the same words, and never touches the
|
|
135
|
+
running runtime: the command keeps logging with the settings logging started with.
|
|
135
136
|
|
|
136
137
|
Args:
|
|
137
|
-
services: The composition's services; only ``
|
|
138
|
+
services: The composition's services; only ``check_logging_config`` is used.
|
|
138
139
|
config: The configuration :func:`load_config` returned.
|
|
139
|
-
env_file: The ``--env-file`` path, or None; logging reads its ``LOG_*`` lines from it.
|
|
140
140
|
|
|
141
141
|
Returns:
|
|
142
|
-
None, or the refusal
|
|
142
|
+
None, or the refusal.
|
|
143
143
|
"""
|
|
144
144
|
try:
|
|
145
|
-
services.
|
|
145
|
+
services.check_logging_config(config)
|
|
146
146
|
except InvalidLoggingConfigError as exc:
|
|
147
147
|
return exc
|
|
148
148
|
return None
|
|
@@ -196,10 +196,10 @@ def require_config(ctx: click.Context, cli_ctx: CLIContext) -> Config:
|
|
|
196
196
|
|
|
197
197
|
|
|
198
198
|
__all__ = [
|
|
199
|
+
"check_logging",
|
|
199
200
|
"echo_load_traceback",
|
|
200
201
|
"load_config",
|
|
201
202
|
"report_load_failure",
|
|
202
203
|
"require_config",
|
|
203
|
-
"restart_logging",
|
|
204
204
|
"start_logging",
|
|
205
205
|
]
|
|
@@ -7,7 +7,7 @@ eliminating duplication between module entry (__main__.py) and console script
|
|
|
7
7
|
Contents:
|
|
8
8
|
* :func:`init_logging` - idempotent logging initialization from the ``[lib_log_rich]``
|
|
9
9
|
section and the ``LOG_*`` variables (the environment, plus the ``LOG_*`` lines of a ``.env``).
|
|
10
|
-
* :func:`
|
|
10
|
+
* :func:`check_logging_config` - refuse another configuration's logging settings without touching the runtime.
|
|
11
11
|
* :class:`InvalidLoggingConfigError` - the ``[lib_log_rich]`` section or a ``LOG_*`` variable
|
|
12
12
|
cannot configure logging.
|
|
13
13
|
* :func:`_build_runtime_config` - constructs RuntimeConfig from layered sources.
|
|
@@ -100,10 +100,12 @@ class InvalidLoggingConfigError(ConfigurationError):
|
|
|
100
100
|
"""lib_log_rich refuses its settings: one ``<key>: <reason>`` in :attr:`problems` per problem.
|
|
101
101
|
|
|
102
102
|
The settings are the ``[lib_log_rich]`` section plus any ``LOG_*`` variable. A problem the
|
|
103
|
-
type check of the section finds names the key and never repeats the refused value
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
type check of the section finds names the key and never repeats the refused value; one no
|
|
104
|
+
single key owns (TLS over UDP for Graylog) reads ``lib_log_rich: <reason>``. A value only
|
|
105
|
+
lib_log_rich itself refuses, such as an unknown level in ``LOG_CONSOLE_LEVEL`` or in the
|
|
106
|
+
section's ``console_level``, is reported in lib_log_rich's own words, which name the setting
|
|
107
|
+
and repeat the value (``lib_log_rich: Invalid runtime settings: console_level: Unknown log
|
|
108
|
+
level: 'bogus'``).
|
|
107
109
|
|
|
108
110
|
Attributes:
|
|
109
111
|
problems: One line per refused setting.
|
|
@@ -128,15 +130,33 @@ _PROJECT_MARKERS = ("pyproject.toml", ".git")
|
|
|
128
130
|
|
|
129
131
|
|
|
130
132
|
def _problems(error: BaseException) -> list[str]:
|
|
131
|
-
"""One line per problem
|
|
133
|
+
"""One line per problem: key and reason from the first pydantic error in ``error``'s chain.
|
|
134
|
+
|
|
135
|
+
A pydantic problem never repeats the refused value; one no single key owns (a model-wide
|
|
136
|
+
check) has no key and reads ``lib_log_rich: <reason>``. Without a pydantic error in the chain,
|
|
137
|
+
the line is lib_log_rich's own first line, which may repeat the value
|
|
138
|
+
(``Invalid runtime settings: console_level: Unknown log level: 'bogus'``).
|
|
139
|
+
"""
|
|
132
140
|
cause: BaseException | None = error
|
|
133
141
|
while cause is not None and not isinstance(cause, ValidationError):
|
|
134
142
|
cause = cause.__cause__ or cause.__context__
|
|
135
143
|
if cause is None:
|
|
136
144
|
# Not a pydantic error (e.g. an unknown level name in a LOG_* variable): lib_log_rich's
|
|
137
|
-
# own first line
|
|
145
|
+
# own first line.
|
|
138
146
|
return [f"lib_log_rich: {str(error).splitlines()[0]}"]
|
|
139
|
-
return [f"
|
|
147
|
+
return [f"{_problem_key(item['loc'])}: {item['msg']}" for item in cause.errors()]
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _problem_key(loc: tuple[int | str, ...]) -> str:
|
|
151
|
+
"""``lib_log_rich.<key>`` for a problem located at a key, bare ``lib_log_rich`` for a model-wide one.
|
|
152
|
+
|
|
153
|
+
Example:
|
|
154
|
+
>>> _problem_key(("rate_limit",))
|
|
155
|
+
'lib_log_rich.rate_limit'
|
|
156
|
+
>>> _problem_key(())
|
|
157
|
+
'lib_log_rich'
|
|
158
|
+
"""
|
|
159
|
+
return ".".join(["lib_log_rich", *(str(part) for part in loc)])
|
|
140
160
|
|
|
141
161
|
|
|
142
162
|
def _nearest_dotenv() -> Path | None:
|
|
@@ -281,35 +301,39 @@ def init_logging(config: Config, *, dotenv_path: str | None = None) -> None:
|
|
|
281
301
|
lib_log_rich.runtime.attach_std_logging()
|
|
282
302
|
|
|
283
303
|
|
|
284
|
-
def
|
|
285
|
-
"""
|
|
304
|
+
def check_logging_config(config: Config) -> None:
|
|
305
|
+
"""Refuse ``config``'s logging settings as :func:`init_logging` would, without touching the runtime.
|
|
286
306
|
|
|
287
307
|
:func:`init_logging` returns at once while a runtime is running, so a configuration loaded
|
|
288
308
|
after logging started (``config --profile``'s reload) would never have its logging settings
|
|
289
|
-
judged.
|
|
290
|
-
|
|
291
|
-
|
|
309
|
+
judged. lib_log_rich's ``validate_config`` refuses exactly what its ``init`` refuses, with the
|
|
310
|
+
same message and the same ``LOG_*`` overrides, and neither reads nor replaces the running
|
|
311
|
+
runtime, so logging keeps running with the settings it started with, on every thread.
|
|
292
312
|
|
|
293
313
|
Args:
|
|
294
314
|
config: Already-loaded layered configuration object.
|
|
295
|
-
dotenv_path: As for :func:`init_logging`.
|
|
296
315
|
|
|
297
316
|
Raises:
|
|
298
|
-
InvalidLoggingConfigError: As for :func:`init_logging
|
|
317
|
+
InvalidLoggingConfigError: As for :func:`init_logging`, with the same problem lines.
|
|
299
318
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
319
|
+
Example:
|
|
320
|
+
>>> check_logging_config(Config({"lib_log_rich": {"console_level": "info"}}, {}))
|
|
321
|
+
>>> try:
|
|
322
|
+
... check_logging_config(Config({"lib_log_rich": {"rate_limit": "100:60"}}, {}))
|
|
323
|
+
... except InvalidLoggingConfigError as exc:
|
|
324
|
+
... print(exc)
|
|
325
|
+
lib_log_rich.rate_limit: Input should be a valid tuple
|
|
303
326
|
"""
|
|
304
|
-
|
|
305
|
-
lib_log_rich.runtime.
|
|
306
|
-
|
|
327
|
+
try:
|
|
328
|
+
lib_log_rich.runtime.validate_config(_build_runtime_config(config))
|
|
329
|
+
except ValueError as exc: # pydantic's ValidationError is a ValueError
|
|
330
|
+
raise InvalidLoggingConfigError(_problems(exc)) from exc
|
|
307
331
|
|
|
308
332
|
|
|
309
333
|
__all__ = [
|
|
310
334
|
"InvalidLoggingConfigError",
|
|
311
335
|
"LoggingConfigModel",
|
|
336
|
+
"check_logging_config",
|
|
312
337
|
"init_logging",
|
|
313
338
|
"log_variables_hidden",
|
|
314
|
-
"restart_logging",
|
|
315
339
|
]
|
|
@@ -20,28 +20,28 @@ from .config import (
|
|
|
20
20
|
get_default_config_path_in_memory,
|
|
21
21
|
)
|
|
22
22
|
from .email import EmailSpy
|
|
23
|
-
from .logging import
|
|
23
|
+
from .logging import check_logging_config_in_memory, init_logging_in_memory
|
|
24
24
|
|
|
25
25
|
# Static conformance assertions
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
27
|
from bitranox_template_py_cli.application.ports import (
|
|
28
|
+
CheckLoggingConfig,
|
|
28
29
|
GetConfig,
|
|
29
30
|
GetDefaultConfigPath,
|
|
30
31
|
InitLogging,
|
|
31
|
-
RestartLogging,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
_assert_get_config: GetConfig = get_config_in_memory
|
|
35
35
|
_assert_get_default_config_path: GetDefaultConfigPath = get_default_config_path_in_memory
|
|
36
36
|
_assert_init_logging: InitLogging = init_logging_in_memory
|
|
37
|
-
|
|
37
|
+
_assert_check_logging_config: CheckLoggingConfig = check_logging_config_in_memory
|
|
38
38
|
|
|
39
39
|
__all__ = [
|
|
40
40
|
"EmailSpy",
|
|
41
|
+
"check_logging_config_in_memory",
|
|
41
42
|
"deploy_configuration_in_memory",
|
|
42
43
|
"display_config_in_memory",
|
|
43
44
|
"get_config_in_memory",
|
|
44
45
|
"get_default_config_path_in_memory",
|
|
45
46
|
"init_logging_in_memory",
|
|
46
|
-
"restart_logging_in_memory",
|
|
47
47
|
]
|
|
@@ -63,17 +63,18 @@ def init_logging_in_memory(config: Config, *, dotenv_path: str | None = None) ->
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def
|
|
67
|
-
"""
|
|
66
|
+
def check_logging_config_in_memory(config: Config) -> None:
|
|
67
|
+
"""Refuse nothing: the test runtime ignores the configuration, so no setting in it can break it.
|
|
68
|
+
|
|
69
|
+
:func:`init_logging_in_memory` starts a fixed runtime whatever the configuration holds.
|
|
68
70
|
|
|
69
71
|
Args:
|
|
70
|
-
config: Unused; the parameter exists to satisfy the ``
|
|
71
|
-
dotenv_path: Unused for the same reason.
|
|
72
|
+
config: Unused; the parameter exists to satisfy the ``CheckLoggingConfig`` protocol.
|
|
72
73
|
|
|
73
74
|
Example:
|
|
74
75
|
>>> from lib_layered_config import Config
|
|
75
|
-
>>>
|
|
76
|
+
>>> check_logging_config_in_memory(Config({"lib_log_rich": {"rate_limit": "100:60"}}, {}))
|
|
76
77
|
"""
|
|
77
78
|
|
|
78
79
|
|
|
79
|
-
__all__ = ["
|
|
80
|
+
__all__ = ["check_logging_config_in_memory", "init_logging_in_memory"]
|
|
@@ -109,24 +109,24 @@ class InitLogging(Protocol):
|
|
|
109
109
|
def __call__(self, config: Config, *, dotenv_path: str | None = None) -> None: ...
|
|
110
110
|
|
|
111
111
|
|
|
112
|
-
class
|
|
113
|
-
"""
|
|
112
|
+
class CheckLoggingConfig(Protocol):
|
|
113
|
+
"""Refuse ``config``'s logging settings as ``InitLogging`` would, leaving the running runtime alone.
|
|
114
114
|
|
|
115
115
|
For a configuration loaded after logging is running; a refused setting raises
|
|
116
|
-
``InvalidLoggingConfigError``
|
|
116
|
+
``InvalidLoggingConfigError`` and logging keeps running with the settings it started with.
|
|
117
117
|
"""
|
|
118
118
|
|
|
119
|
-
def __call__(self, config: Config
|
|
119
|
+
def __call__(self, config: Config) -> None: ...
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
__all__ = [
|
|
123
|
+
"CheckLoggingConfig",
|
|
123
124
|
"DeployConfiguration",
|
|
124
125
|
"DisplayConfig",
|
|
125
126
|
"GetConfig",
|
|
126
127
|
"GetDefaultConfigPath",
|
|
127
128
|
"InitLogging",
|
|
128
129
|
"LoadEmailConfigFromDict",
|
|
129
|
-
"RestartLogging",
|
|
130
130
|
"SendEmail",
|
|
131
131
|
"SendNotification",
|
|
132
132
|
]
|
|
@@ -19,20 +19,20 @@ from ..adapters.email.sender import (
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
# Logging services
|
|
22
|
-
from ..adapters.logging.setup import
|
|
22
|
+
from ..adapters.logging.setup import check_logging_config, init_logging
|
|
23
23
|
|
|
24
24
|
# Static conformance assertions — pyright verifies that each adapter function
|
|
25
25
|
# structurally satisfies its corresponding Protocol at type-check time.
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
27
|
from ..adapters.memory.email import EmailSpy
|
|
28
28
|
from ..application.ports import (
|
|
29
|
+
CheckLoggingConfig,
|
|
29
30
|
DeployConfiguration,
|
|
30
31
|
DisplayConfig,
|
|
31
32
|
GetConfig,
|
|
32
33
|
GetDefaultConfigPath,
|
|
33
34
|
InitLogging,
|
|
34
35
|
LoadEmailConfigFromDict,
|
|
35
|
-
RestartLogging,
|
|
36
36
|
SendEmail,
|
|
37
37
|
SendNotification,
|
|
38
38
|
)
|
|
@@ -45,7 +45,7 @@ if TYPE_CHECKING:
|
|
|
45
45
|
_assert_send_notification: SendNotification = send_notification
|
|
46
46
|
_assert_load_email_config_from_dict: LoadEmailConfigFromDict = load_email_config_from_dict
|
|
47
47
|
_assert_init_logging: InitLogging = init_logging
|
|
48
|
-
|
|
48
|
+
_assert_check_logging_config: CheckLoggingConfig = check_logging_config
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
@dataclass(frozen=True, slots=True)
|
|
@@ -60,7 +60,7 @@ class AppServices:
|
|
|
60
60
|
send_notification: SendNotification
|
|
61
61
|
load_email_config_from_dict: LoadEmailConfigFromDict
|
|
62
62
|
init_logging: InitLogging
|
|
63
|
-
|
|
63
|
+
check_logging_config: CheckLoggingConfig
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
def build_production() -> AppServices:
|
|
@@ -74,7 +74,7 @@ def build_production() -> AppServices:
|
|
|
74
74
|
send_notification=send_notification,
|
|
75
75
|
load_email_config_from_dict=load_email_config_from_dict,
|
|
76
76
|
init_logging=init_logging,
|
|
77
|
-
|
|
77
|
+
check_logging_config=check_logging_config,
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
|
|
@@ -91,12 +91,12 @@ def build_testing(*, spy: EmailSpy | None = None) -> AppServices:
|
|
|
91
91
|
"""
|
|
92
92
|
from ..adapters.memory import ( # noqa: PLC0415 - deferred: keeps in-memory test doubles out of the production import path
|
|
93
93
|
EmailSpy,
|
|
94
|
+
check_logging_config_in_memory,
|
|
94
95
|
deploy_configuration_in_memory,
|
|
95
96
|
display_config_in_memory,
|
|
96
97
|
get_config_in_memory,
|
|
97
98
|
get_default_config_path_in_memory,
|
|
98
99
|
init_logging_in_memory,
|
|
99
|
-
restart_logging_in_memory,
|
|
100
100
|
)
|
|
101
101
|
|
|
102
102
|
email_spy = spy if spy is not None else EmailSpy()
|
|
@@ -111,7 +111,7 @@ def build_testing(*, spy: EmailSpy | None = None) -> AppServices:
|
|
|
111
111
|
# The real translation: an in-memory one would let every CLI test skip it.
|
|
112
112
|
load_email_config_from_dict=load_email_config_from_dict,
|
|
113
113
|
init_logging=init_logging_in_memory,
|
|
114
|
-
|
|
114
|
+
check_logging_config=check_logging_config_in_memory,
|
|
115
115
|
)
|
|
116
116
|
|
|
117
117
|
|
|
@@ -119,13 +119,13 @@ __all__ = [
|
|
|
119
119
|
"AppServices",
|
|
120
120
|
"build_production",
|
|
121
121
|
"build_testing",
|
|
122
|
+
"check_logging_config",
|
|
122
123
|
"deploy_configuration",
|
|
123
124
|
"display_config",
|
|
124
125
|
"get_config",
|
|
125
126
|
"get_default_config_path",
|
|
126
127
|
"init_logging",
|
|
127
128
|
"load_email_config_from_dict",
|
|
128
|
-
"restart_logging",
|
|
129
129
|
"send_email",
|
|
130
130
|
"send_notification",
|
|
131
131
|
]
|