Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -94,6 +94,17 @@ def requestResults(text, pipeline):
|
|
94 |
return labels[0]
|
95 |
|
96 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
LOG_FILE = "usage_log.jsonl" # Use temporary file path for Hugging Face Spaces
|
99 |
|
@@ -107,8 +118,9 @@ def log_interaction(user_input, model_name, predictions):
|
|
107 |
|
108 |
try:
|
109 |
os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
|
110 |
-
|
111 |
-
|
|
|
112 |
print("[INFO] Logged interaction successfully.")
|
113 |
except Exception as e:
|
114 |
print(f"[ERROR] Could not write log entry: {e}")
|
|
|
94 |
return labels[0]
|
95 |
|
96 |
import os
|
97 |
+
import logging
|
98 |
+
|
99 |
+
logging.basicConfig(
|
100 |
+
level=logging.INFO,
|
101 |
+
format='%(asctime)s [%(levelname)s] %(message)s',
|
102 |
+
handlers=[
|
103 |
+
logging.FileHandler("app.log",mode='w')
|
104 |
+
|
105 |
+
]
|
106 |
+
|
107 |
+
)
|
108 |
|
109 |
LOG_FILE = "usage_log.jsonl" # Use temporary file path for Hugging Face Spaces
|
110 |
|
|
|
118 |
|
119 |
try:
|
120 |
os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
|
121 |
+
# with open(LOG_FILE, "a") as log_file:
|
122 |
+
# log_file.write(json.dumps(log_entry) + "\n")
|
123 |
+
logging.info(log_entry)
|
124 |
print("[INFO] Logged interaction successfully.")
|
125 |
except Exception as e:
|
126 |
print(f"[ERROR] Could not write log entry: {e}")
|