From 26695e20c0a802a0304d58fa48d983cded0aa69e Mon Sep 17 00:00:00 2001 From: srfoster65 <135555068+srfoster65@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:02:04 +0100 Subject: [PATCH 1/4] chore: ensure SLC is reset between each test --- tests/test_print.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_print.py b/tests/test_print.py index 89cd143..626995a 100644 --- a/tests/test_print.py +++ b/tests/test_print.py @@ -4,12 +4,23 @@ import logging +import pytest + from simple_logging_config import configure_logging logger = logging.getLogger(__name__) +@pytest.fixture(scope="function", autouse=True) +def configure(): + """ + Ensure logging is reset after each test. + """ + yield + configure_logging().reset() + + class TestPrintFunctions: """ Class to test default config . @@ -21,7 +32,7 @@ def test_str(self): """ slc = configure_logging() out = str(slc) - assert ("Logging config: dual" in out) + assert "Logging config: dual" in out def test_repr(self): """ From 905fedf18e49ff7b5a6ca4dc1f6eba5a064da59c Mon Sep 17 00:00:00 2001 From: srfoster65 <135555068+srfoster65@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:02:22 +0100 Subject: [PATCH 2/4] chore: update readme to align with code --- readme.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 1f3805a..d127602 100644 --- a/readme.md +++ b/readme.md @@ -57,8 +57,8 @@ configure_logging(**vars(args)) Your script will now accept additional CLI paramaters to configure logging at runtime as shown below. ```python -usage: myscript.py [-h] [-v | --slc_level LEVELS] [--slc_modules [MODULES ...]] [--slc_log_file_path LOG_FILE_PATH] - [--slc_backup_count BACKUP_COUNT] [--slc_config {dual,dual_rotating,dual_detailed,console,file,rotating_file}] +usage: myscript.py [-h] [-v | --slc-level LEVELS] [--slc-modules [MODULES ...]] [--slc-log-file-path LOG_FILE_PATH] + [--slc-backup-count BACKUP_COUNT] [--slc-config {dual,dual_rotating,dual_detailed,console,file,rotating_file}] Test Program @@ -66,19 +66,19 @@ options: -h, --help show this help message and exit -v, --verbose The level of logging verbosity for the default handler. Use multiple times (up to -vvv) for increased verbosity. - --slc_level LEVELS, --slc_levels LEVELS + --slc-level LEVELS, --slc-levels LEVELS The log level(s) to be applied to attached handlers. This value can be a single integer or a string representing a defined log level. Or it can be a string representing a dictionary where key/value pairs are handler names and the log level to be associated with that handler - --slc_modules [MODULES ...] + --slc-modules [MODULES ...] The names of the modules to be logged. If omitted all modules are logged. - --slc_log_file_path LOG_FILE_PATH + --slc-log-file-path LOG_FILE_PATH The path the log file will be saved to. If this is a folder, the log file will be saved to this folder with the file name derived from the name of the calling script. Otherwise, assume this is a full path to a named log file. - --slc_backup_count BACKUP_COUNT + --slc-backup-count BACKUP_COUNT An integer specifying The number of backup log files to retain. - --slc_config {dual,dual_rotating,dual_detailed,console,file,rotating_file} + --slc-config {dual,dual_rotating,dual_detailed,console,file,rotating_file} The name of the logging config to be used. ``` From 52ddc4807454d8e1c0241bc31025d706ce35b2aa Mon Sep 17 00:00:00 2001 From: srfoster65 <135555068+srfoster65@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:02:45 +0100 Subject: [PATCH 3/4] chore: update pdm.lock --- pdm.lock | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/pdm.lock b/pdm.lock index e1bcccc..5feadc3 100644 --- a/pdm.lock +++ b/pdm.lock @@ -2,11 +2,11 @@ # It is not intended for manual editing. [metadata] -groups = ["default", "dev", "test", "docs"] +groups = ["default", "test", "docs"] cross_platform = true static_urls = false lock_version = "4.3" -content_hash = "sha256:120e6761f1977da493e2b864a5e6cf711463c109da1a04aff6354c1df0e0ee63" +content_hash = "sha256:499272cfc7cb00c794ade70ff441d841ae2b0ee2cf599ad058278dc76d87c47e" [[package]] name = "arg-init" @@ -31,27 +31,6 @@ files = [ {file = "Babel-2.13.0.tar.gz", hash = "sha256:04c3e2d28d2b7681644508f836be388ae49e0cfe91465095340395b60d00f210"}, ] -[[package]] -name = "black" -version = "23.10.0" -requires_python = ">=3.8" -summary = "The uncompromising code formatter." -dependencies = [ - "click>=8.0.0", - "mypy-extensions>=0.4.3", - "packaging>=22.0", - "pathspec>=0.9.0", - "platformdirs>=2", -] -files = [ - {file = "black-23.10.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:30b78ac9b54cf87bcb9910ee3d499d2bc893afd52495066c49d9ee6b21eee06e"}, - {file = "black-23.10.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:0e232f24a337fed7a82c1185ae46c56c4a6167fb0fe37411b43e876892c76699"}, - {file = "black-23.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:31946ec6f9c54ed7ba431c38bc81d758970dd734b96b8e8c2b17a367d7908171"}, - {file = "black-23.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:c870bee76ad5f7a5ea7bd01dc646028d05568d33b0b09b7ecfc8ec0da3f3f39c"}, - {file = "black-23.10.0-py3-none-any.whl", hash = "sha256:e223b731a0e025f8ef427dd79d8cd69c167da807f5710add30cdf131f13dd62e"}, - {file = "black-23.10.0.tar.gz", hash = "sha256:31b9f87b277a68d0e99d2905edae08807c007973eaa609da5f0c62def6b7c0bd"}, -] - [[package]] name = "certifi" version = "2023.7.22" @@ -341,16 +320,6 @@ files = [ {file = "mkdocs_material_extensions-1.3.tar.gz", hash = "sha256:f0446091503acb110a7cab9349cbc90eeac51b58d1caa92a704a81ca1e24ddbd"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -requires_python = ">=3.5" -summary = "Type system extensions for programs checked with the mypy type checker." -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "packaging" version = "23.2" From 1fbd7523e6f60a381aaddaf7068a9ead831436e0 Mon Sep 17 00:00:00 2001 From: srfoster65 <135555068+srfoster65@users.noreply.github.com> Date: Sun, 22 Oct 2023 21:03:06 +0100 Subject: [PATCH 4/4] update git ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index f88c241..ade1162 100644 --- a/.gitignore +++ b/.gitignore @@ -174,4 +174,3 @@ test-results.xml # vscode config files /.vscode/ -