|
12 | 12 | import java.util.Map; |
13 | 13 | import java.util.Set; |
14 | 14 | import java.util.Map.Entry; |
| 15 | +import java.util.Date; |
| 16 | +import java.text.SimpleDateFormat; |
| 17 | + |
| 18 | +import java.io.File; |
| 19 | +import java.io.FileWriter; |
| 20 | +import java.io.BufferedWriter; |
| 21 | +import java.io.IOException; |
15 | 22 |
|
16 | 23 | import javax.ws.rs.Consumes; |
17 | 24 | import javax.ws.rs.GET; |
@@ -193,6 +200,30 @@ public Map<String,Object> getFeedbackOverride(@HeaderParam("uid") String uid, |
193 | 200 | return new Feedback_OverrideConflictLabel_Controller().getFeedback(feedbackBatch, fn_modelFnList, fn_reportIDList, uid); |
194 | 201 | } |
195 | 202 |
|
| 203 | + @PUT |
| 204 | + @Path("logEvent/{event}/{message}") |
| 205 | + @Consumes(MediaType.APPLICATION_JSON) |
| 206 | + public void logEvent(@HeaderParam("uid") String uid, |
| 207 | + @PathParam("event") String event, |
| 208 | + @PathParam("message") String message) |
| 209 | + throws Exception { |
| 210 | + File dir = new File(Storage_Controller.getModelListFolder()); |
| 211 | + File log = new File(dir, "log.txt"); |
| 212 | + |
| 213 | + if(!log.exists()){ |
| 214 | + log.createNewFile(); |
| 215 | + } |
| 216 | + |
| 217 | + SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); |
| 218 | + String time = dateFormat.format(new Date()); |
| 219 | + |
| 220 | + BufferedWriter output = new BufferedWriter(new FileWriter(log, true)); |
| 221 | + |
| 222 | + System.out.println("["+time+"]\t["+uid+"]\t["+event+"]\t"+message+"\n"); |
| 223 | + output.write("["+time+"]\t["+uid+"]\t["+event+"]\t"+message+"\n"); |
| 224 | + output.close(); |
| 225 | + } |
| 226 | + |
196 | 227 | /** |
197 | 228 | * Create a data set with an initial training set and models built on the training set |
198 | 229 | * @return |
|
0 commit comments