Skip to content

Commit

Permalink
Add logging option for successful queries
Browse files Browse the repository at this point in the history
  • Loading branch information
nck-mlcnv committed Oct 31, 2024
1 parent dd48631 commit dce1e84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public Path convert(String value) {

@Parameter(names = {"--version", "-v"}, description = "Outputs the version number of the program and result ontology.")
private boolean version;

@Parameter(names = {"--log-success", "-ls"}, description = "Log successful queries.")
public static boolean logSuccess = false;
}

private static final Logger LOGGER = LoggerFactory.getLogger(MainController.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.jpountz.xxhash.StreamingXXHash64;
import net.jpountz.xxhash.XXHashFactory;
import org.aksw.iguana.cc.config.elements.ConnectionConfig;
import org.aksw.iguana.cc.controller.MainController;
import org.aksw.iguana.cc.query.handler.QueryHandler;
import org.aksw.iguana.cc.utils.http.RequestFactory;
import org.aksw.iguana.cc.worker.ResponseBodyProcessor;
Expand Down Expand Up @@ -468,10 +469,12 @@ private static HttpExecutionResult createFailedResultDuringResponse(

private void logExecution(ExecutionStats execution) {
switch (execution.endState()) {
case SUCCESS -> LOGGER.debug("{}\t:: Successfully executed query: [queryID={}].", this, execution.queryID());
case SUCCESS -> {
if (MainController.Args.logSuccess) LOGGER.info("{}\t:: Successfully executed query: [queryID={}, duration={}].", this, execution.queryID(), execution.duration());
}
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
case HTTP_ERROR -> LOGGER.warn("{}\t:: HTTP Error occurred during query execution: [queryID={}, httpError={}].", this, execution.queryID(), execution.httpStatusCode().orElse(-1));
case MISCELLANEOUS_EXCEPTION -> LOGGER.warn("{}\t:: Miscellaneous exception occurred during query execution: [queryID={}, exception={}].", this, execution.queryID(), execution.error().orElse(null));
case MISCELLANEOUS_EXCEPTION -> LOGGER.warn("{}\t:: Miscellaneous exception occurred during query execution: [queryID={}].", this, execution.queryID(), execution.error().orElse(null));
}
}

Expand Down

0 comments on commit dce1e84

Please sign in to comment.