Added log configuration for android.

Updated leveldb android implementation.
Fixed ormlite null bug.
This commit is contained in:
Adrian Tiberius 2015-06-17 17:17:40 +02:00
parent 3292f73cb9
commit 3fc6455c0e
5 changed files with 174 additions and 17 deletions

View File

@ -101,8 +101,8 @@ public class MainActivity extends ActionBarActivity {
Log.v(TAG, "222");
long duration = ethereumManager.connect();
ConsoleFragment consoleeFrag = (ConsoleFragment)getSupportFragmentManager().findFragmentById(R.id.console);
consoleeFrag.updateDuration(duration);
//ConsoleFragment consoleeFrag = (ConsoleFragment)getSupportFragmentManager().findFragmentById(R.id.console);
//consoleeFrag.updateDuration(duration);
Log.v(TAG, "333");
while(true) {

View File

@ -43,10 +43,11 @@ tasks.withType(JavaCompile){
}
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0'
apt "com.google.dagger:dagger-compiler:2.0"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile (project(':ethereumj-core')) {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: "commons-codec", module: "commons-codec"
exclude group: "commons-logging", module: "commons-logging"
exclude group: "org.apache.commons", module: "commons-pool2"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "log4j", module: "apache-log4j-extras"
@ -60,8 +61,10 @@ dependencies {
compile "com.j256.ormlite:ormlite-android:4.48"
compile "org.glassfish:javax.annotation:10.0-b28"
compile "org.iq80.leveldb:leveldb:0.7"
compile 'org.slf4j:slf4j-android:1.7.12'
compile 'javax.persistence:persistence-api:1.0.2'
compile "com.github.tony19:logback-android-core:1.1.1-3"
compile "com.github.tony19:logback-android-classic:1.1.1-3"
compile "org.slf4j:slf4j-api:1.7.12"
compile "javax.persistence:persistence-api:1.0.2"
compile group: 'com.thetransactioncompany', name: 'jsonrpc2-server', version: '1.11'
compile group: "com.thetransactioncompany", name: "jsonrpc2-server", version: "1.11"
}

View File

@ -0,0 +1,138 @@
<configuration>
<property name="LOG_DIR" value="/data/data/org.ethereum.android_app/files" />
<!-- Create a logcat appender -->
<appender name="logcat" class="ch.qos.logback.classic.android.LogcatAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<encoder>
<pattern>%msg</pattern>
</encoder>
</appender>
<!-- Create a file appender for TRACE-level messages -->
<appender name="TraceLog" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${LOG_DIR}/trace.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!-- Create a file appender for DEBUG-level messages -->
<appender name="DebugLog" class="ch.qos.logback.core.FileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<file>${LOG_DIR}/debug.log</file>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="core" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="net" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="db" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="peerdiscovery" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="io.netty" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="wire" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="wallet" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="dump" level="OFF">
<appender-ref ref="logcat" />
</logger>
<logger name="trie" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="block" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="blockqueue" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="general" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="peermonitor" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="VM" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="main" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="state" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="repository" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="blockchain" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="txs" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="gas" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="execute" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<logger name="hsqldb.db" level="ERROR">
<appender-ref ref="logcat" />
</logger>
<root level="ERROR">
<appender-ref ref="logcat" />
</root>
</configuration>

View File

@ -3,6 +3,8 @@ package org.ethereum.android.datasource;
import org.ethereum.config.SystemProperties;
import org.ethereum.datasource.KeyValueDataSource;
import org.fusesource.leveldbjni.JniDBFactory;
import org.fusesource.leveldbjni.internal.JniDB;
import org.iq80.leveldb.CompressionType;
import org.iq80.leveldb.DB;
import org.iq80.leveldb.DBIterator;
@ -53,12 +55,10 @@ public class LevelDbDataSource implements KeyValueDataSource {
Options options = new Options();
options.createIfMissing(true);
options.compressionType(CompressionType.NONE);
org.iq80.leveldb.Logger logger1 = new org.iq80.leveldb.Logger() {
public void log(String message) {
logger.debug(message);
}
};
options.logger(logger1);
options.blockSize(10 * 1024);
options.writeBufferSize(10 * 1024);
options.cacheSize(0);
try {
logger.debug("Opening database");
File dbLocation = new File(SystemProperties.CONFIG.databaseDir());
@ -68,8 +68,24 @@ public class LevelDbDataSource implements KeyValueDataSource {
destroyDB(fileLocation);
}
logger.debug("Initializing new or existing database: '{}'", fileLocation.getAbsolutePath());
db = Iq80DBFactory.factory.open(fileLocation, options);
logger.debug("Initializing new or existing database: '{}'", name);
try {
db = JniDBFactory.factory.open(fileLocation, options);
} catch (Throwable e) {
System.out.println("No native version of LevelDB found");
}
String cpu = System.getProperty("sun.arch.data.model");
String os = System.getProperty("os.name");
if (db instanceof JniDB)
System.out.println("Native version of LevelDB loaded for: " + os + "." + cpu + "bit");
else{
System.out.println("Pure Java version of LevelDB loaded");
db = Iq80DBFactory.factory.open(fileLocation, options);
}
} catch (IOException ioe) {
logger.error(ioe.getMessage(), ioe);
@ -143,4 +159,4 @@ public class LevelDbDataSource implements KeyValueDataSource {
logger.error("Failed to find the db file on the close: {} ", name);
}
}
}
}

View File

@ -196,7 +196,7 @@ public class OrmLiteBlockStoreDatabase extends OrmLiteSqliteOpenHelper implement
try {
GenericRawResults<String[]> rawResults = getBlockDao().queryRaw("select max(number) from block");
List<String[]> results = rawResults.getResults();
if (results.size() > 0 && results.get(0).length > 0) {
if (results.get(0)[0] != null) {
bestNumber = Long.valueOf(results.get(0)[0]);
}
} catch(java.sql.SQLException e) {