diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index e0591e2..9d5a369 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -70,3 +70,8 @@ jobs: - name: Test | Run pytest run: ${{ inputs.run-test-command }} + - name: Test | Run End-to-End App Test + run: ./tests/e2e_test_app.py + + - name: Test | Check End-to-End Test Results + run: [ "$(wc -l < e2e-test-app-stderr.log)" -eq 3 ] && [ "$(wc -l < e2e-test-logfile.log)" -eq 3 ] && [ ! -s "e2e-test-logfile_root.log" ] diff --git a/src/readylog/__init__.py b/src/readylog/__init__.py index bf588fd..0c95a29 100644 --- a/src/readylog/__init__.py +++ b/src/readylog/__init__.py @@ -5,13 +5,14 @@ def create_dict_config( - logfile: Path, + logfile: Path | str, app_name: str, console_log_level: str | int = "WARNING", file_log_level: str | int = "DEBUG", console_handler_factory: Callable = StreamHandler, file_handler_factory: Callable = FileHandler, ) -> dict[str, str]: + logfile = Path(logfile) console_log_level = _checkLevel(console_log_level) file_log_level = _checkLevel(file_log_level) min_level = getLevelName(min(console_log_level, file_log_level)) diff --git a/tests/e2e_test_app.py b/tests/e2e_test_app.py new file mode 100755 index 0000000..f596db8 --- /dev/null +++ b/tests/e2e_test_app.py @@ -0,0 +1,34 @@ +#!/usr/bin/env -S uv run --script +# +# /// script +# requires-python = ">=3.11" +# dependencies = [ +# "readylog", +# ] +# +# [tool.uv.sources] +# readylog = { path = "..", editable = true } +# /// + +from logging import getLogger +from logging.config import dictConfig + +from readylog import create_dict_config +from readylog.decorators import debug + +logging_configuration = create_dict_config( + "e2e-test-logfile.log", "e2e-test-app", console_log_level="DEBUG" +) +dictConfig(logging_configuration) + +logger = getLogger(__name__) + + +@debug +def greet(greeting: str, name: str) -> None: + return f"{greeting.title()}, {name.title()}" + + +logger.debug("e2e-test-app runs") + +greet("hello", "world")