-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SK-1649: Added validations and logging
- Loading branch information
1 parent
a4374a0
commit 4a4909b
Showing
36 changed files
with
1,321 additions
and
371 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 +1 @@ | ||
from skyflow.error._skyflow_error import SkyflowError | ||
from ._skyflow_error import SkyflowError |
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,4 +1,13 @@ | ||
class SkyflowError(Exception): | ||
def __init__(self, message): | ||
super().__init__(message) | ||
self.message = message | ||
def __init__(self, | ||
message, | ||
http_code, | ||
request_id = None, | ||
grpc_code = None, | ||
http_status = None, | ||
details = None, | ||
logger = None, | ||
logger_method = None): | ||
|
||
logger_method(message, http_code, request_id, grpc_code, http_status, details, logger) | ||
super().__init__() |
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 +1 @@ | ||
from ._utils import generate_bearer_token, generate_bearer_token_from_creds | ||
from ._utils import generate_bearer_token, generate_bearer_token_from_creds, is_expired |
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,2 +1,6 @@ | ||
from ..utils.enums import LogLevel, Env | ||
from ._utils import get_credentials, get_vault_url, get_client_configuration, get_base_url, format_scope, get_redaction_type, construct_invoke_connection_request, build_field_records | ||
from ._skyflow_messages import SkyflowMessages | ||
from ._version import SDK_VERSION | ||
from ._logger import Logger | ||
from ._log_helpers import log_error, log_info | ||
from ._utils import get_credentials, get_vault_url, get_client_configuration, get_base_url, format_scope, get_redaction_type, construct_invoke_connection_request, get_metrics, parse_insert_response, handle_exception, parse_update_record_response, parse_delete_response, parse_detokenize_response, parse_tokenize_response, parse_query_response, parse_get_response |
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,27 @@ | ||
from .enums import LogLevel | ||
from . import Logger | ||
|
||
|
||
def log_info(message, interface, logger = None): | ||
formatted_message = '{} {}'.format(interface, message) | ||
logger.info(formatted_message) | ||
|
||
def log_error(message, http_code, request_id=None, grpc_code=None, http_status=None, details=None, logger=None): | ||
if not logger: | ||
logger = Logger(LogLevel.ERROR) | ||
|
||
log_data = { | ||
'http_code': http_code, | ||
'message': message | ||
} | ||
|
||
if grpc_code is not None: | ||
log_data['grpc_code'] = grpc_code | ||
if http_status is not None: | ||
log_data['http_status'] = http_status | ||
if request_id is not None: | ||
log_data['request_id'] = request_id | ||
if details is not None: | ||
log_data['details'] = details | ||
|
||
logger.error(log_data) |
Oops, something went wrong.