Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging option for successful queries #298

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading