-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9197e78
commit 92765e5
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
"""Provide hooks to run after project is generated.""" | ||
|
||
from pathlib import Path | ||
import shutil | ||
|
||
|
||
if not {{ cookiecutter.add_docs }}: | ||
shutil.rmtree("docs") | ||
Path(".readthedocs.yaml").unlink() | ||
|
||
|
||
if not {{ cookiecutter.add_fastapi }}: | ||
Path("tests/test_api.py").unlink() | ||
Path("src/{{ cookiecutter.project_slug }}/api.py").unlink() | ||
Path("src/{{ cookiecutter.project_slug }}/models.py").unlink() | ||
Path("src/{{ cookiecutter.project_slug }}/logging.py").unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
python/{{cookiecutter.project_slug}}/src/{{cookiecutter.project_slug}}/logging.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Configure application logging.""" | ||
|
||
import logging | ||
|
||
|
||
def initialize_logs(log_level: int = logging.DEBUG) -> None: | ||
"""Configure logging. | ||
:param log_level: global log level to set | ||
""" | ||
log_filename = f"{__package__}.log" | ||
logging.basicConfig( | ||
filename=log_filename, | ||
format="[%(asctime)s] - %(name)s - %(levelname)s : %(message)s", | ||
) | ||
logger = logging.getLogger(__package__) | ||
logger.setLevel(log_level) |