Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Otherwise, delete the commented-out lines.
### Configuration Management
- [ ] **USER:** Rename `.config/.env.example` to `.config/.env.dev` and update required secrets.
- [ ] **USER:** Update required application settings in `.config/config.dev.toml`.
- [ ] **USER:** Update values to match your `.env.dev` and `.config/config.dev.toml` settings in `src/<your_package_name>/utils/config.py`.
- [ ] **USER:** Update values to match your `.env.dev` and `.config/config.dev.toml` settings in `src/<your_package_name>/core/config.py`.

### Project Documents
- [ ] **USER:** Delete `.gitkeep` in `data/`, `notebooks/` and `res/` if applicable, empty directories will disappear from GitHub.
Expand Down
8 changes: 4 additions & 4 deletions docs/INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ python-project-blueprint/
├── res/ # Static resources (images, etc.)
├── src/
│ └── package_name # Core logic
│ ├── utils/ # Shared utilities
│ ├── core/ # Core utilities
│ │ ├── __init__.py
│ │ ├── config.py
│ │ └── logger.py
Expand Down Expand Up @@ -135,7 +135,7 @@ strict naming conventions are enforced.
This directory orchestrates the application's configuration using a **Layered Configuration Strategy**.
This ensures a clean separation between structural application settings (TOML) and sensitive credentials (.env).

The configuration loading logic (found in `src/package_name/utils/config.py`) follows this hierarchy, where lower layers override upper ones:
The configuration loading logic (found in `src/package_name/core/config.py`) follows this hierarchy, where lower layers override upper ones:

1. **Pydantic Defaults:** Defined in the code (failsafe values).
2. **`config.{APP_ENV}.toml`:** Structural configuration (ports, hosts, feature flags). **Committed to Git.**
Expand Down Expand Up @@ -179,7 +179,7 @@ This directory is strictly ignored by Git to prevent accidental leakage of logs,
- **`mypy_cache/`**: Stores incremental type-checking data to significantly speed up subsequent `mypy` runs by only analyzing changed files.

### Advanced Logging Features
The logger (configured in `src/package_name/utils/logger.py`) includes several production-grade processors:
The logger (configured in `src/package_name/core/logger.py`) includes several production-grade processors:

* **Security Masking:** An automated `mask_sensitive_data` processor scans log events for keys like `password` and replaces them with `********` to prevent credential leakage.
* **Environment Context:** Every log entry is automatically tagged with the current `APP_ENV` via a dedicated processor, making it easy to filter logs.
Expand Down Expand Up @@ -486,7 +486,7 @@ By using the **src-layout**, we ensure that the code is only importable when pro
The internal structure follows a modular design to keep the source code of your application organized:

* **`main.py`**: The central entry point for the application. It orchestrates the startup, including configuration loading and logger initialization.
* **`utils/`**: A dedicated subdirectory for utilities:
* **`core/`**: A dedicated subdirectory for utilities:
* **`config.py`**: Contains the Pydantic-based configuration logic that implements the layered loading strategy.
* **`logger.py`**: Defines the `structlog` integrated with the standard `logging` module, including security masking.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/package_name/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import structlog

from package_name.utils.config import Settings
from package_name.utils.logger import setup_logging
from package_name.core.config import Settings
from package_name.core.logger import setup_logging

logger: structlog.stdlib.BoundLogger = structlog.get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import tomllib
from unittest.mock import MagicMock, patch

from src.package_name.utils.config import Settings
from src.package_name.core.config import Settings


def test_settings_load_from_toml(clean_env):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import structlog

from src.package_name.utils.logger import setup_logging
from src.package_name.core.logger import setup_logging


def test_logging_masking_and_env(capsys):
Expand Down