diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ca7daa5a..ccca252b 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.14.2 +current_version = 0.14.3 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(-(?P[a-z]+)(?P\d+))? diff --git a/coverage.xml b/coverage.xml index 4bbc9403..f6eb53cc 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -11,7 +11,16 @@ + + + + + + + + + @@ -21,9 +30,9 @@ - + - + @@ -33,7 +42,7 @@ - + @@ -97,216 +106,216 @@ + - - - - - - - + + + + + - + - + - - - - + + + + - + - - + + + + - - - - - - - - + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - + + + + + + + - + - + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + - + - - + + - + - + - - + + - - - - - - - + + + + + + + - + - - + + - + - - + + - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + + @@ -320,79 +329,79 @@ - - - - + + + - + - + - - - - - + + + + + - - + + - + + + - - - - - - - - - - + + + + + + + - - + + - - - - - - + + + + + + - - - - - + + + + + - - + + - - + + - - + + + + @@ -400,227 +409,227 @@ + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - - - + + - + + - - - - - - - - + + + + + + + - - - - - - - - - + + + + + + + + + + - - - - - + + + + - - + + - - + + - - + + - - + + - - + + + - - - - + + + + - - - + + - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - + + + + + + + + - - + + + - + - - - - + + + - - - - - - + + + + + + + - + + + - - - - + - - - - - - + + + + + + + - - - - + + + + - - - + + + - - - - + + + - - + + - - + + + - - + + - - + + - + - + + @@ -677,23 +686,23 @@ - - - - - - + + + + + - - - - - - - - - + + + + + + + + + + @@ -713,78 +722,78 @@ - - + - - - - - - - - - - + + + + + + + + + + - + - + - + + + - - - - + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - - + + + - + - - + diff --git a/docs/recipes/fastapi.md b/docs/recipes/fastapi.md index 82c706e7..e2ff9827 100644 --- a/docs/recipes/fastapi.md +++ b/docs/recipes/fastapi.md @@ -26,7 +26,8 @@ from contextlib import asynccontextmanager from fastapi import Body, FastAPI, Query from fastapi.responses import RedirectResponse # from loguru import logger -import logging as logger +# import logging as logger +from . import logger from pydantic import BaseModel, EmailStr from sqlalchemy import Column, ForeignKey, Select, String from sqlalchemy.orm import relationship diff --git a/docs/recipes/loggingExample.md b/docs/recipes/loggingExample.md index e5f39787..af5b515c 100644 --- a/docs/recipes/loggingExample.md +++ b/docs/recipes/loggingExample.md @@ -13,7 +13,8 @@ import secrets import threading # from loguru import logger -import logging as logger +# import logging as logger +from . import logger from tqdm import tqdm from dsg_lib.common_functions import logging_config diff --git a/dsg_lib/__init__.py b/dsg_lib/__init__.py index fda496d8..d55ea68f 100644 --- a/dsg_lib/__init__.py +++ b/dsg_lib/__init__.py @@ -3,10 +3,22 @@ DevSetGo Library ========= -DevSetGo Library is a Python library offering reusable functions for efficient coding. It includes file operations, calendar utilities, pattern matching, advanced logging with loguru, FastAPI endpoints, async database handling, and email validation. Designed for ease of use and versatility, it's a valuable tool for Python developers. - Author: Mike Ryan License: MIT """ +from datetime import date + +__version__ = "0.14.3" +__author__ = "Mike Ryan" +__license__ = "MIT" +__copyright__ = f"Copyright© 2021-{date.today().year}" +__site__ = "https://github.com/devsetgo/devsetgo_lib" + + +# Import the library's modules +import logging -__version__ = "0.14.2" +# Configure the library's logger +LOGGER = logging.getLogger("devsetgo_lib") +LOGGER.addHandler(logging.NullHandler()) +LOGGER.propagate = False diff --git a/dsg_lib/async_database_functions/__import_sqlalchemy.py b/dsg_lib/async_database_functions/__import_sqlalchemy.py index ef1aa06b..161cdde9 100644 --- a/dsg_lib/async_database_functions/__import_sqlalchemy.py +++ b/dsg_lib/async_database_functions/__import_sqlalchemy.py @@ -24,12 +24,14 @@ Date Updated: 2024/07/26 """ -# from loguru import logger -import logging as logger from typing import Tuple from packaging import version as packaging_version +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Importing AsyncDatabase class from local module async_database diff --git a/dsg_lib/async_database_functions/async_database.py b/dsg_lib/async_database_functions/async_database.py index 150f7ee9..ede01d8c 100644 --- a/dsg_lib/async_database_functions/async_database.py +++ b/dsg_lib/async_database_functions/async_database.py @@ -51,8 +51,8 @@ # from loguru import logger -import logging as logger - +# import logging as logger +from .. import LOGGER as logger from .database_config import BASE, DBConfig diff --git a/dsg_lib/async_database_functions/database_config.py b/dsg_lib/async_database_functions/database_config.py index 1a2d1b85..3eacf072 100644 --- a/dsg_lib/async_database_functions/database_config.py +++ b/dsg_lib/async_database_functions/database_config.py @@ -43,11 +43,12 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -import logging as logger from contextlib import asynccontextmanager from typing import Dict +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from .__import_sqlalchemy import import_sqlalchemy ( diff --git a/dsg_lib/async_database_functions/database_operations.py b/dsg_lib/async_database_functions/database_operations.py index 0557695c..cffa2e78 100644 --- a/dsg_lib/async_database_functions/database_operations.py +++ b/dsg_lib/async_database_functions/database_operations.py @@ -29,14 +29,15 @@ License: MIT """ -# from loguru import logger -import logging as logger import time from typing import Dict, List, Type from sqlalchemy import delete from sqlalchemy.ext.declarative import DeclarativeMeta +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from .__import_sqlalchemy import import_sqlalchemy # Importing AsyncDatabase class from local module async_database from .async_database import AsyncDatabase diff --git a/dsg_lib/common_functions/calendar_functions.py b/dsg_lib/common_functions/calendar_functions.py index 7574cfb2..b965f05e 100644 --- a/dsg_lib/common_functions/calendar_functions.py +++ b/dsg_lib/common_functions/calendar_functions.py @@ -51,7 +51,8 @@ License: MIT """ # from loguru import logger -import logging as logger +# import logging as logger +from .. import LOGGER as logger def get_month(month: int) -> str: diff --git a/dsg_lib/common_functions/email_validation.py b/dsg_lib/common_functions/email_validation.py index 59ebe9fe..29ca5301 100644 --- a/dsg_lib/common_functions/email_validation.py +++ b/dsg_lib/common_functions/email_validation.py @@ -36,8 +36,6 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -import logging as logger from enum import Enum from typing import Dict, List, Union @@ -48,6 +46,10 @@ validate_email, ) +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + class DNSType(Enum): """ diff --git a/dsg_lib/common_functions/file_functions.py b/dsg_lib/common_functions/file_functions.py index 4140744a..183c8fba 100644 --- a/dsg_lib/common_functions/file_functions.py +++ b/dsg_lib/common_functions/file_functions.py @@ -40,14 +40,16 @@ # Import required modules import csv import json -# from loguru import logger -import logging as logger import os import random from datetime import datetime from pathlib import Path from typing import List +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Set the path to the directory where the files are located directory_to_files: str = "data" diff --git a/dsg_lib/common_functions/folder_functions.py b/dsg_lib/common_functions/folder_functions.py index de69d1e2..768c32eb 100644 --- a/dsg_lib/common_functions/folder_functions.py +++ b/dsg_lib/common_functions/folder_functions.py @@ -37,13 +37,15 @@ License: MIT """ -# from loguru import logger -import logging as logger import re from datetime import datetime from pathlib import Path from typing import List, Tuple +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + # Define the directory where the files are located directory_to__files: str = "data" file_directory = f"{directory_to__files}/csv" diff --git a/dsg_lib/common_functions/patterns.py b/dsg_lib/common_functions/patterns.py index 3bc97ba8..e9930360 100644 --- a/dsg_lib/common_functions/patterns.py +++ b/dsg_lib/common_functions/patterns.py @@ -38,10 +38,12 @@ License: MIT """ -# from loguru import logger -import logging as logger import re +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger + def pattern_between_two_char( text_string: str, left_characters: str, right_characters: str diff --git a/dsg_lib/fastapi_functions/http_codes.py b/dsg_lib/fastapi_functions/http_codes.py index 586163a8..1abc95f3 100644 --- a/dsg_lib/fastapi_functions/http_codes.py +++ b/dsg_lib/fastapi_functions/http_codes.py @@ -28,10 +28,11 @@ Date: 2024/05/16 License: MIT """ -# from loguru import logger -import logging as logger from typing import Dict, List, Union +# from loguru import logger +# import logging as logger +from .. import LOGGER as logger from ._all_codes import ALL_HTTP_CODES # TODO: Create a way to extend the ALL_HTTP_CODES dictionary with custom codes. diff --git a/dsg_lib/fastapi_functions/system_health_endpoints.py b/dsg_lib/fastapi_functions/system_health_endpoints.py index 1a2f9647..f93b78df 100644 --- a/dsg_lib/fastapi_functions/system_health_endpoints.py +++ b/dsg_lib/fastapi_functions/system_health_endpoints.py @@ -68,13 +68,12 @@ License: MIT """ -# Importing database connector module -# from loguru import logger -import logging as logger # Import necessary modules import time import tracemalloc +# Importing database connector module +from loguru import logger from packaging import version as packaging_version from dsg_lib.fastapi_functions.http_codes import generate_code_dict @@ -382,7 +381,7 @@ async def get_heapdump(): } ) - logger.debug(f"Heap dump returned {heap_dump}") + logger.info(f"Heap dump returned {heap_dump}") memory_use = tracemalloc.get_traced_memory() return { "memory_use": { diff --git a/examples/fastapi_example.py b/examples/fastapi_example.py index 837e22fd..ef2b3b10 100644 --- a/examples/fastapi_example.py +++ b/examples/fastapi_example.py @@ -5,14 +5,13 @@ License: MIT """ import datetime -# from loguru import logger -import logging as logger import secrets import time from contextlib import asynccontextmanager from fastapi import Body, FastAPI, Query from fastapi.responses import RedirectResponse +from loguru import logger from pydantic import BaseModel, EmailStr from sqlalchemy import Column, ForeignKey, Select, String from sqlalchemy.orm import relationship @@ -28,7 +27,7 @@ from dsg_lib.fastapi_functions import system_health_endpoints # , system_tools_endpoints logging_config.config_log( - logging_level="INFO", log_serializer=False, log_name="log.log" + logging_level="INFO", log_serializer=False, logging_directory="log", log_name="log.log", intercept_standard_logging=False ) # Create a DBConfig instance config = { @@ -345,4 +344,4 @@ async def read_list_of_records( if __name__ == "__main__": import uvicorn - uvicorn.run(app, host="127.0.0.1", port=5000) + uvicorn.run(app, host="127.0.0.1", port=5001) diff --git a/pyproject.toml b/pyproject.toml index 8b972c66..a66b584f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "hatchling.build" [project] name = "devsetgo_lib" -version = "0.14.2" +version = "0.14.3" requires-python = ">=3.9" description = """ DevSetGo Library is a Python library offering reusable functions for efficient coding. It includes file operations, calendar utilities, pattern matching, advanced logging with loguru, FastAPI endpoints, async database handling, and email validation. Designed for ease of use and versatility, it's a valuable tool for Python developers.