Skip to content

Commit 5c2214a

Browse files
authored
Add logging option for successful queries (#298)
- also unrelated minor fix to logging
1 parent 3f4de12 commit 5c2214a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/java/org/aksw/iguana/cc/controller/MainController.java

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public Path convert(String value) {
4040

4141
@Parameter(names = {"--version", "-v"}, description = "Outputs the version number of the program and result ontology.")
4242
private boolean version;
43+
44+
@Parameter(names = {"--log-success", "-ls"}, description = "Log successful queries.")
45+
public static boolean logSuccess = false;
4346
}
4447

4548
private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);

src/main/java/org/aksw/iguana/cc/worker/impl/SPARQLProtocolWorker.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.jpountz.xxhash.StreamingXXHash64;
55
import net.jpountz.xxhash.XXHashFactory;
66
import org.aksw.iguana.cc.config.elements.ConnectionConfig;
7+
import org.aksw.iguana.cc.controller.MainController;
78
import org.aksw.iguana.cc.query.handler.QueryHandler;
89
import org.aksw.iguana.cc.utils.http.RequestFactory;
910
import org.aksw.iguana.cc.worker.ResponseBodyProcessor;
@@ -468,10 +469,12 @@ private static HttpExecutionResult createFailedResultDuringResponse(
468469

469470
private void logExecution(ExecutionStats execution) {
470471
switch (execution.endState()) {
471-
case SUCCESS -> LOGGER.debug("{}\t:: Successfully executed query: [queryID={}].", this, execution.queryID());
472+
case SUCCESS -> {
473+
if (MainController.Args.logSuccess) LOGGER.info("{}\t:: Successfully executed query: [queryID={}, duration={}].", this, execution.queryID(), execution.duration());
474+
}
472475
case TIMEOUT -> LOGGER.warn("{}\t:: Timeout during query execution: [queryID={}, duration={}].", this, execution.queryID(), execution.duration()); // TODO: look for a possibility to add the query string for better logging
473476
case HTTP_ERROR -> LOGGER.warn("{}\t:: HTTP Error occurred during query execution: [queryID={}, httpError={}].", this, execution.queryID(), execution.httpStatusCode().orElse(-1));
474-
case MISCELLANEOUS_EXCEPTION -> LOGGER.warn("{}\t:: Miscellaneous exception occurred during query execution: [queryID={}, exception={}].", this, execution.queryID(), execution.error().orElse(null));
477+
case MISCELLANEOUS_EXCEPTION -> LOGGER.warn("{}\t:: Miscellaneous exception occurred during query execution: [queryID={}].", this, execution.queryID(), execution.error().orElse(null));
475478
}
476479
}
477480

0 commit comments

Comments
 (0)