-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logging): add interfaces for logging feature (#29)
This commit adds interfaces for logging features used for logging the request & response (the implementation will be either NoneSdkLogger or SdkLogger) and also an abstract of logging a particular message that would be implemented by SDK users or the default logger (i.e. ConsoleLogger in our case).
- Loading branch information
1 parent
c9c22ed
commit 8e924ee
Showing
6 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
__all__ = [ | ||
'client', | ||
'factories', | ||
'types' | ||
'types', | ||
'logger' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
__all__=[ | ||
"api_logger", | ||
"logger" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters