Skip to content

Commit

Permalink
feat: Added logger config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh619-sudo committed Oct 10, 2024
1 parent bf8f7ff commit 82635f2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions qbosdk/apis/api_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""
API Base class with util functions
"""
import sys
import logging
import logging.config
import json
from typing import List, Dict, Generator

Expand All @@ -10,6 +12,9 @@
from ..exceptions import WrongParamsError, InvalidTokenError, QuickbooksOnlineSDKError, \
NoPrivilegeError, NotFoundItemError, ExpiredTokenError, InternalServerError

logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("requests").setLevel(logging.WARNING)
logger = logging.getLogger(__name__)

class ApiBase:
Expand Down Expand Up @@ -56,6 +61,7 @@ def _query_get_all(self, object_type: str, url: str) -> List[Dict]:
response = requests.get(url=request_url.format(start_position), headers=api_headers)

if response.status_code == 200:
print('bajsdbkjas')
logger.debug('Response for get request for url: %s, %s', url, response.text)
data = json.loads(response.text)
query_response = data['QueryResponse']
Expand Down Expand Up @@ -254,12 +260,13 @@ def _post_request(self, data, api_url):
json=data
)

logger.debug('Payload for post request: %s', data)

if response.status_code == 200:
logger.debug('Response for post request: %s', response.text)
result = json.loads(response.text)
return result

logger.debug('Payload for post request: %s', data)
logger.info('Response for post request: %s', response.text)

if response.status_code == 400:
Expand Down Expand Up @@ -306,13 +313,13 @@ def _post_file(self, data, api_url):
data=data
)

logger.debug('Payload for post request: %s', data)

if response.status_code == 200:
logger.debug('Response for post request: %s', response.text)
result = json.loads(response.text)
return result['AttachableResponse'][0]['Attachable']


logger.debug('Payload for post request: %s', data)

logger.info('Response for post request: %s', response.text)

if response.status_code == 400:
Expand Down

0 comments on commit 82635f2

Please sign in to comment.