Housekeeping and migrated prints to logging

This commit is contained in:
Lyncoln
2026-10-28 16:45:54 -04:00
parent e456902a1d
commit 71f27e27e0
7 changed files with 38 additions and 79 deletions
+13 -14
View File
@@ -1,5 +1,6 @@
import json
import os
import logging
def buildSave(action, outputs):
savedata_log = os.environ.get("LOGS_SAVE_DATA_ACCESS", "false").lower() == "true"
@@ -39,7 +40,7 @@ def buildSave(action, outputs):
pass
if savedata_log:
print(f"Data saved by {action.name} to {action.savepath}")
logging.info(f"Data saved by {action.name} to {action.savepath}")
return outputs
def loadSave(action, outputs):
@@ -53,7 +54,7 @@ def loadSave(action, outputs):
outputs[load_name] = load_data[load_name]
if savedata_log:
print(f"Data loaded by {action.name} from {action.savepath}")
logging.info(f"Data loaded by {action.name} from {action.savepath}")
return outputs
def saveRow(action, outputs, resolved):
@@ -87,8 +88,8 @@ def saveRow(action, outputs, resolved):
elif "resolved" in item:
value = resolved[item["resolved"]]
except KeyError as error:
print(f"The save data for {error} was not located in its respective dictionary during {action.name}")
print("Bypassing database save")
logging.error(f"The save data for {error} was not located in its respective dictionary during {action.name}")
logging.error("Bypassing database save")
return False
values.append(value)
@@ -137,7 +138,7 @@ def saveRow(action, outputs, resolved):
database.execute(query, tuple(values))
except sqlite3.IntegrityError as error:
print(f"Unable to complete database write during {action.name}: {error}")
logging.error(f"Unable to complete database write during {action.name}: {error}")
return False
#database.execute(
@@ -148,7 +149,7 @@ def saveRow(action, outputs, resolved):
#database.commit()
#database.close()
print(f"Successfully saved data to {table} during {action.name}")
logging.info(f"Successfully saved data to {table} during {action.name}")
return True
@@ -206,8 +207,8 @@ def readRow(action, resolved, outputs):
""",
(value,)
)
#print("DEBUG READROW TARGET ITEM")
#print(value)
logging.debug("DEBUG READROW TARGET ITEM")
logging.debug(value)
result = cursor.fetchone()
@@ -216,15 +217,13 @@ def readRow(action, resolved, outputs):
for column_index, output_name in exports.items():
dbtarget = result[column_index]
outputs[output_name] = dbtarget# result[column_index]
#print("DEBUGGING DATABASE LINE EXTRACTION IN READROW")
#print(outputs[output_name])
#print(dbtarget)
logging.debug("DEBUGGING DATABASE LINE EXTRACTION IN READROW")
logging.debug(outputs[output_name])
logging.debug(dbtarget)
return resolved, outputs
else:
print(f"Search target {value} not found in database table {table}")
logging.info(f"Search target {value} not found in database table {table}")
return resolved, outputs
#print("READROW SEARCH RESULT")
#print(target)
return resolved, outputs