mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 08:56:21 +02:00
Implement logging strategy (#444)
* Logging strategy and convert all prints() to logging invocations
This commit is contained in:
parent
3e0651222b
commit
dd70aade11
117 changed files with 1216 additions and 667 deletions
|
|
@ -49,9 +49,6 @@ class Api:
|
|||
|
||||
url = f"{self.url}{path}"
|
||||
|
||||
# print("uri:", url)
|
||||
# print(json.dumps(request, indent=4))
|
||||
|
||||
# Invoke the API, input is passed as JSON
|
||||
resp = requests.post(url, json=request, timeout=self.timeout)
|
||||
|
||||
|
|
@ -59,8 +56,6 @@ class Api:
|
|||
if resp.status_code != 200:
|
||||
raise ProtocolException(f"Status code {resp.status_code}")
|
||||
|
||||
# print(resp.text)
|
||||
|
||||
try:
|
||||
# Parse the response as JSON
|
||||
object = resp.json()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
|
||||
import logging
|
||||
|
||||
from . exceptions import *
|
||||
from . types import ConfigValue
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Config:
|
||||
|
||||
def __init__(self, api):
|
||||
|
|
@ -33,7 +37,7 @@ class Config:
|
|||
for v in object["values"]
|
||||
]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error("Failed to parse config get response", exc_info=True)
|
||||
raise ProtocolException("Response not formatted correctly")
|
||||
|
||||
def put(self, values):
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@
|
|||
import datetime
|
||||
import time
|
||||
import base64
|
||||
import logging
|
||||
|
||||
from . types import DocumentMetadata, ProcessingMetadata, Triple
|
||||
from .. knowledge import hash, Uri, Literal
|
||||
from . exceptions import *
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def to_value(x):
|
||||
if x["e"]: return Uri(x["v"])
|
||||
return Literal(x["v"])
|
||||
|
|
@ -112,7 +115,7 @@ class Library:
|
|||
for v in object["document-metadatas"]
|
||||
]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error("Failed to parse document list response", exc_info=True)
|
||||
raise ProtocolException(f"Response not formatted correctly")
|
||||
|
||||
def get_document(self, user, id):
|
||||
|
|
@ -145,7 +148,7 @@ class Library:
|
|||
tags = doc["tags"]
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error("Failed to parse document response", exc_info=True)
|
||||
raise ProtocolException(f"Response not formatted correctly")
|
||||
|
||||
def update_document(self, user, id, metadata):
|
||||
|
|
@ -192,7 +195,7 @@ class Library:
|
|||
tags = doc["tags"]
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error("Failed to parse document update response", exc_info=True)
|
||||
raise ProtocolException(f"Response not formatted correctly")
|
||||
|
||||
def remove_document(self, user, id):
|
||||
|
|
@ -266,6 +269,6 @@ class Library:
|
|||
for v in object["processing-metadatas"]
|
||||
]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.error("Failed to parse processing list response", exc_info=True)
|
||||
raise ProtocolException(f"Response not formatted correctly")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue