From 04f109ff7f31a2fc353ab052e1f7d9842282f405 Mon Sep 17 00:00:00 2001 From: Andy Kruth Date: Mon, 18 Jan 2016 10:12:27 -0600 Subject: [PATCH] [orientdb] adding slf4j logging --- orientdb/pom.xml | 5 +++++ .../java/com/yahoo/ycsb/db/OrientDBClient.java | 17 +++++++++++------ orientdb/src/main/resources/log4j.properties | 8 ++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 orientdb/src/main/resources/log4j.properties diff --git a/orientdb/pom.xml b/orientdb/pom.xml index 8a6b1d5d2d..407f75a7bf 100644 --- a/orientdb/pom.xml +++ b/orientdb/pom.xml @@ -53,6 +53,11 @@ LICENSE file. 4.12 test + + org.slf4j + slf4j-log4j12 + 1.7.10 + diff --git a/orientdb/src/main/java/com/yahoo/ycsb/db/OrientDBClient.java b/orientdb/src/main/java/com/yahoo/ycsb/db/OrientDBClient.java index 853f9ab328..5d576e3ff4 100644 --- a/orientdb/src/main/java/com/yahoo/ycsb/db/OrientDBClient.java +++ b/orientdb/src/main/java/com/yahoo/ycsb/db/OrientDBClient.java @@ -34,6 +34,8 @@ import com.yahoo.ycsb.DBException; import com.yahoo.ycsb.Status; import com.yahoo.ycsb.StringByteIterator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.HashMap; @@ -70,6 +72,8 @@ public class OrientDBClient extends DB { private static final String ORIENTDB_DOCUMENT_TYPE = "document"; + private final Logger log = LoggerFactory.getLogger(getClass()); + @Override public void init() throws DBException { Properties props = getProperties(); @@ -86,7 +90,7 @@ public void init() throws DBException { throw new DBException(String.format("Required property \"%s\" missing for OrientDBClient", URL_PROPERTY)); } - System.err.println("OrientDB loading database url = " + url); + log.info("OrientDB loading database url = " + url); // If using a remote database, use the OServerAdmin interface to connect if (url.startsWith(OEngineRemote.NAME)) { @@ -101,12 +105,12 @@ public void init() throws DBException { if (server.existsDatabase()) { if (newdb && !dotransactions) { - System.err.println("OrientDB dropping and recreating fresh db on remote server."); + log.info("OrientDB dropping and recreating fresh db on remote server."); server.dropDatabase(remoteStorageType); server.createDatabase(server.getURL(), ORIENTDB_DOCUMENT_TYPE, remoteStorageType); } } else { - System.err.println("OrientDB database not found, creating fresh db"); + log.info("OrientDB database not found, creating fresh db"); server.createDatabase(server.getURL(), ORIENTDB_DOCUMENT_TYPE, remoteStorageType); } @@ -121,12 +125,12 @@ public void init() throws DBException { if (db.exists()) { db.open(user, password); if (newdb && !dotransactions) { - System.err.println("OrientDB dropping and recreating fresh db."); + log.info("OrientDB dropping and recreating fresh db."); db.drop(); db.create(); } } else { - System.err.println("OrientDB database not found, creating fresh db"); + log.info("OrientDB database not found, creating fresh db"); db.create(); } } catch (ODatabaseException e) { @@ -134,7 +138,7 @@ public void init() throws DBException { } } - System.err.println("OrientDB connection created with " + url); + log.info("OrientDB connection created with " + url); dictionary = db.getMetadata().getIndexManager().getDictionary(); if (!db.getMetadata().getSchema().existsClass(CLASS)) { db.getMetadata().getSchema().createClass(CLASS); @@ -226,6 +230,7 @@ public Status scan(String table, String startkey, int recordcount, Set f Vector> result) { if (isRemote) { // Iterator methods needed for scanning are Unsupported for remote database connections. + log.warn("OrientDB scan operation is not implemented for remote database connections."); return Status.NOT_IMPLEMENTED; } diff --git a/orientdb/src/main/resources/log4j.properties b/orientdb/src/main/resources/log4j.properties new file mode 100644 index 0000000000..0ede1d4c14 --- /dev/null +++ b/orientdb/src/main/resources/log4j.properties @@ -0,0 +1,8 @@ +# Root logger option +log4j.rootLogger=INFO, stderr + +# Direct log messages to stderr +log4j.appender.stderr=org.apache.log4j.ConsoleAppender +log4j.appender.stderr.Target=System.err +log4j.appender.stderr.layout=org.apache.log4j.PatternLayout +log4j.appender.stderr.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n