Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logging): add interfaces for logging feature #29

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
3 changes: 2 additions & 1 deletion apimatic_core_interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = [
'client',
'factories',
'types'
'types',
'logger'
]
4 changes: 4 additions & 0 deletions apimatic_core_interfaces/logger/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__all__=[
"api_logger",
"logger"
]
25 changes: 25 additions & 0 deletions apimatic_core_interfaces/logger/api_logger.py
Original file line number Diff line number Diff line change
@@ -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.
"""
...
19 changes: 19 additions & 0 deletions apimatic_core_interfaces/logger/logger.py
Original file line number Diff line number Diff line change
@@ -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.
"""
...
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading