Skip to content
Open
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
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Placeholder for future updates and new features.
## [1.3.1] - 2026-05-04

### Changed
- Centralised logging setup (closes #39): all config variants now expose a single `util.setup_logging()` function so `main.py` is uniform regardless of the chosen config format. `util__yaml.py` and `util__hocon.py` gain a `setup_logging()` wrapper; a new `util__none.py` provides a standalone `setup_logging()` for the no-config case (renamed to `util.py` by the post-generate hook).

## [1.3.0] - 2026-01-27

Expand Down
9 changes: 7 additions & 2 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
'config/prod.conf',
]

files_config_none = [
f'{module_dir}/util__none.py',
]

files_ci_gitlab = {
".gitlab-ci.yml",
}
Expand Down Expand Up @@ -141,16 +145,17 @@ def handle_cli():
def handle_config():
config_file = '{{ cookiecutter.config_file }}'
if config_file == 'yaml':
_delete_files(files_config_hocon)
_delete_files(files_config_hocon + files_config_none)
shutil.rmtree(f'{module_dir}/res')
_rename_files(f'src/**/*__yaml.py', '__yaml', '')
elif config_file == 'hocon':
_delete_files(files_config_yaml)
_delete_files(files_config_yaml + files_config_none)
_rename_files(f'src/**/*__hocon.py', '__hocon', '')
else:
_delete_files(files_config_hocon + files_config_yaml + ['tests/test_util.py'])
os.rmdir(f'{module_dir}/res')
os.rmdir('config')
_rename_files(f'src/**/*__none.py', '__none', '')


def handle_formatter():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "at-python-template"
version = "1.3.0"
version = "1.3.1"
description = "This is the official Python Project Template of Alexander Thamm GmbH (AT)"
authors = [
"Christian Baur <christian.baur@alexanderthamm.com>",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def test_config_yaml():
def test_config_none():
check_project(
settings={'config_file': 'none'},
files_non_existent=['config', 'src/{module_name}/util.py', 'tests/util.py',
'src/{module_name}/res'])
files_existent=['src/{module_name}/util.py'],
files_non_existent=['config', 'tests/util.py', 'src/{module_name}/res'])


def test_formatter_black_pip():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import logging
from {{ cookiecutter.module_name }} import util

logger = logging.getLogger('{{ cookiecutter.module_name }}')


def main():
util.setup_logging()
logger.info("Looks like you're all set up. Let's get going!")
# TODO your journey starts here
print("hello :)")


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,8 @@ def logging_setup(config: ConfigTree):
level = logging.NOTSET
logging.basicConfig(format=fmt, level=logging.WARNING)
logger.setLevel(level)


def setup_logging(config_path: Union[str, Path] = None):
"""Load config and configure logging in one call."""
logging_setup(load_config(config_path))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logging


def setup_logging():
"""Configure basic logging for the application."""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s.%(msecs)03d [%(levelname)s]: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ def logging_setup(config: Dict):
level = logging.NOTSET
logging.basicConfig(format=fmt, level=logging.WARNING)
logger.setLevel(level)


def setup_logging(config_path: Union[str, Path] = 'config/config.yml'):
"""Load config and configure logging in one call."""
logging_setup(load_config(config_path))