diff --git a/README.md b/README.md index 8f37182..dd41b32 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,8 @@ pip install apimatic-core-interfaces | [`ResponseFactory`](apimatic_core_interfaces/factories/response_factory.py) | To convert the client-adapter response into a custom HTTP response | | [`Authentication`](apimatic_core_interfaces/types/authentication.py) | To setup methods for the validation and application of the required authentication scheme | | [`UnionType`](apimatic_core_interfaces/types/union_type.py) | To setup methods for the validation and deserialization of OneOf/AnyOf union types | - +| [`Logger`](apimatic_core_interfaces/logger/logger.py) | An interface for the generic logger facade | +| [`ApiLogger`](apimatic_core_interfaces/logger/api_logger.py) | An interface for logging API requests and responses | ## Enumerations | Name | Description | diff --git a/apimatic_core_interfaces/__init__.py b/apimatic_core_interfaces/__init__.py index 225a1c8..94e6598 100644 --- a/apimatic_core_interfaces/__init__.py +++ b/apimatic_core_interfaces/__init__.py @@ -1,5 +1,6 @@ __all__ = [ 'client', 'factories', - 'types' + 'types', + 'logger' ] \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/__init__.py b/apimatic_core_interfaces/logger/__init__.py new file mode 100644 index 0000000..4e1589c --- /dev/null +++ b/apimatic_core_interfaces/logger/__init__.py @@ -0,0 +1,4 @@ +__all__=[ + "api_logger", + "logger" +] \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/api_logger.py b/apimatic_core_interfaces/logger/api_logger.py new file mode 100644 index 0000000..34ba62d --- /dev/null +++ b/apimatic_core_interfaces/logger/api_logger.py @@ -0,0 +1,25 @@ +from abc import abstractmethod + +class ApiLogger: + """An interface for logging API requests and responses. + + This class should not be instantiated but should be used as a base class + for API Logger classes.""" + + @abstractmethod + def log_request(self, http_request): + """Logs the given HTTP request. + + Args: + http_request (HttpRequest): The HTTP request to log. + """ + ... + + @abstractmethod + def log_response(self, http_response): + """Logs the given HTTP response. + + Args: + http_response (HttpRequest): The HTTP request to log. + """ + ... \ No newline at end of file diff --git a/apimatic_core_interfaces/logger/logger.py b/apimatic_core_interfaces/logger/logger.py new file mode 100644 index 0000000..1090f66 --- /dev/null +++ b/apimatic_core_interfaces/logger/logger.py @@ -0,0 +1,19 @@ +from abc import abstractmethod + + +class Logger: + """An interface for the generic logger facade. + + This class should not be instantiated but should be used as a base class + for Logger classes.""" + + @abstractmethod + def log(self, level, message, params): + """Logs a message with a specified log level and additional parameters. + + Args: + level (int): The log level of the message. + message (str): The message to log. + params (dict): Additional parameters to include in the log message. + """ + ... \ No newline at end of file diff --git a/setup.py b/setup.py index 3a2a13f..ab9bf32 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name='apimatic-core-interfaces', - version='0.1.4', + version='0.1.5', description='An abstract layer of the functionalities provided by apimatic-core-library, requests-client-adapter ' 'and APIMatic SDKs.', long_description=long_description,