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

support for request/response logging #20

Merged
merged 1 commit into from
Sep 5, 2012
Merged
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ _timeouts in seconds_
* org.neo4j.rest.driver="neo4j-rest-graphdb/1.8M07"
* org.neo4j.rest.stream=true
* org.neo4j.rest.batch_transactions=true (convert transaction scope into batch-rest-operations)


* org.neo4j.rest.logging_filter=false (set to true if verbose request/response logging should be enabled)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import javax.ws.rs.core.MediaType;

import com.sun.jersey.api.client.filter.LoggingFilter;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.rest.graphdb.util.Config;
import org.neo4j.rest.graphdb.util.JsonHelper;
Expand Down Expand Up @@ -69,6 +70,9 @@ protected Client createClient() {
client.setReadTimeout(Config.getReadTimeout());
client.setChunkedEncodingSize(8*1024);
userAgent.install(client);
if (Config.useLoggingFilter()) {
client.addFilter(new LoggingFilter());
}
return client;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/neo4j/rest/graphdb/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Config {
public final static String CONFIG_PREFIX = "org.neo4j.rest.";
public static final String CONFIG_STREAM = CONFIG_PREFIX + "stream";
public static final String CONFIG_BATCH_TRANSACTION = CONFIG_PREFIX+"batch_transaction";
public static final String CONFIG_LOG_REQUESTS = CONFIG_PREFIX+"logging_filter";

public static int getConnectTimeout() {
return getTimeout("connect_timeout", 30);
Expand All @@ -42,6 +43,10 @@ public static boolean useBatchTransactions() {
return System.getProperty(CONFIG_BATCH_TRANSACTION,"true").equalsIgnoreCase("true");
}

public static boolean useLoggingFilter() {
return System.getProperty(CONFIG_LOG_REQUESTS,"false").equalsIgnoreCase("true");
}

private static int getTimeout(final String param, final int defaultValue) {
return (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(System.getProperty(CONFIG_PREFIX + param, "" + defaultValue)));
}
Expand Down