diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml
index cc50cbffc7..2c454ff4df 100644
--- a/bootstrap/pom.xml
+++ b/bootstrap/pom.xml
@@ -5,7 +5,7 @@
parent
io.bitsquare
- 0.1.4-SNAPSHOT
+ 0.2.1-SNAPSHOT
4.0.0
diff --git a/bootstrap/src/main/java/io/bitsquare/app/bootstrap/BootstrapNode.java b/bootstrap/src/main/java/io/bitsquare/app/bootstrap/BootstrapNode.java
index c31cd7e224..215b5618a3 100644
--- a/bootstrap/src/main/java/io/bitsquare/app/bootstrap/BootstrapNode.java
+++ b/bootstrap/src/main/java/io/bitsquare/app/bootstrap/BootstrapNode.java
@@ -17,6 +17,7 @@
package io.bitsquare.app.bootstrap;
+import io.bitsquare.app.Logging;
import io.bitsquare.p2p.BootstrapNodes;
import io.bitsquare.p2p.Node;
@@ -52,8 +53,10 @@ public class BootstrapNode {
}
public void start() {
- String name = env.getRequiredProperty(Node.NAME_KEY);
int port = env.getProperty(Node.PORT_KEY, Integer.class, BootstrapNodes.DEFAULT_PORT);
+ String name = env.getRequiredProperty(Node.NAME_KEY);
+ Logging.setup(name + "_" + port);
+
try {
Number160 peerId = Number160.createHash(name);
diff --git a/bootstrap/src/main/resources/logback.xml b/bootstrap/src/main/resources/logback.xml
index e577bdbaac..f38800df0f 100644
--- a/bootstrap/src/main/resources/logback.xml
+++ b/bootstrap/src/main/resources/logback.xml
@@ -23,32 +23,8 @@
-
- .bitsquare/bootstrapNode.log
- false
-
- bootstrapNode_%i.log
- 1
- 10
-
-
-
- 1MB
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n
-
-
-
-
-
-
-
-
-
-
diff --git a/core/pom.xml b/core/pom.xml
index f08196836a..50a1d7b25a 100755
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -6,7 +6,7 @@
parent
io.bitsquare
- 0.1.4-SNAPSHOT
+ 0.2.1-SNAPSHOT
core
@@ -145,16 +145,7 @@
gson
2.2.4
-
- org.controlsfx
- controlsfx
- 8.0.6_20
-
-
- de.jensd
- fontawesomefx
- 8.0.0
-
+
net.glxn
qrgen
@@ -175,11 +166,6 @@
annotations
13.0
-
- eu.hansolo.enzo
- Enzo
- 0.1.5
-
org.fxmisc.easybind
@@ -187,26 +173,6 @@
1.0.2
-
- com.vinumeris
- updatefx
- 1.2
-
-
- org.slf4j
- slf4j-jdk14
-
-
-
-
-
-
diff --git a/core/src/main/java/io/bitsquare/app/Logging.java b/core/src/main/java/io/bitsquare/app/Logging.java
new file mode 100644
index 0000000000..dc1ca1f18e
--- /dev/null
+++ b/core/src/main/java/io/bitsquare/app/Logging.java
@@ -0,0 +1,64 @@
+/*
+ * This file is part of Bitsquare.
+ *
+ * Bitsquare is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bitsquare is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bitsquare. If not, see .
+ */
+
+package io.bitsquare.app;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
+import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
+import ch.qos.logback.core.rolling.RollingFileAppender;
+import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
+
+public class Logging {
+ private static final Logger log = LoggerFactory.getLogger(Logging.class);
+
+ public static void setup(String fileName) {
+ LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
+
+ RollingFileAppender appender = new RollingFileAppender();
+ appender.setContext(loggerContext);
+ appender.setFile(fileName + ".log");
+
+ FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
+ rollingPolicy.setContext(loggerContext);
+ rollingPolicy.setParent(appender);
+ rollingPolicy.setFileNamePattern(fileName + "_%i.log");
+ rollingPolicy.setMinIndex(1);
+ rollingPolicy.setMaxIndex(10);
+ rollingPolicy.start();
+
+ SizeBasedTriggeringPolicy triggeringPolicy = new ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy();
+ triggeringPolicy.setMaxFileSize("1MB");
+ triggeringPolicy.start();
+
+ PatternLayoutEncoder encoder = new PatternLayoutEncoder();
+ encoder.setContext(loggerContext);
+ encoder.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n");
+ encoder.start();
+
+ appender.setEncoder(encoder);
+ appender.setRollingPolicy(rollingPolicy);
+ appender.setTriggeringPolicy(triggeringPolicy);
+ appender.start();
+
+ ch.qos.logback.classic.Logger logbackLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
+ logbackLogger.addAppender(appender);
+ }
+}
diff --git a/core/src/main/java/io/bitsquare/app/Version.java b/core/src/main/java/io/bitsquare/app/Version.java
new file mode 100644
index 0000000000..99a56f43cb
--- /dev/null
+++ b/core/src/main/java/io/bitsquare/app/Version.java
@@ -0,0 +1,32 @@
+/*
+ * This file is part of Bitsquare.
+ *
+ * Bitsquare is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bitsquare is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bitsquare. If not, see .
+ */
+
+package io.bitsquare.app;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Version {
+ private static final Logger log = LoggerFactory.getLogger(Version.class);
+
+ public static final int MAJOR_VERSION = 0;
+ public static final int MINOR_VERSION = 1;
+ public static final int PATCH_VERSION = 3; // Will be used by UpdatedFX
+
+ public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + PATCH_VERSION;
+
+}
diff --git a/core/src/main/java/io/bitsquare/storage/FileManager.java b/core/src/main/java/io/bitsquare/storage/FileManager.java
index 4112b6ba89..af472d40a8 100644
--- a/core/src/main/java/io/bitsquare/storage/FileManager.java
+++ b/core/src/main/java/io/bitsquare/storage/FileManager.java
@@ -82,10 +82,6 @@ public class FileManager {
private final Callable saver;
private T serializable;
- public static void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
- FileManager.uncaughtExceptionHandler = uncaughtExceptionHandler;
- }
-
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor
@@ -100,8 +96,6 @@ public class FileManager {
.setNameFormat("FileManager thread")
.setPriority(Thread.MIN_PRIORITY); // Avoid competing with the GUI thread.
- builder.setUncaughtExceptionHandler(uncaughtExceptionHandler);
-
// An executor that starts up threads when needed and shuts them down later.
this.executor = new ScheduledThreadPoolExecutor(1, builder.build());
this.executor.setKeepAliveTime(5, TimeUnit.SECONDS);
diff --git a/gui/pom.xml b/gui/pom.xml
index a213947cfe..121aada48e 100644
--- a/gui/pom.xml
+++ b/gui/pom.xml
@@ -22,7 +22,7 @@
parent
io.bitsquare
- 0.1.4-SNAPSHOT
+ 0.2.1-SNAPSHOT
4.0.0
@@ -116,5 +116,43 @@
core
${project.parent.version}
+
+
+ com.vinumeris
+ updatefx
+ 1.2
+
+
+
+ org.slf4j
+ slf4j-jdk14
+
+
+
+
+
+
+ com.vinumeris
+ crashfx-client
+ 1.1
+
+
+
+ org.controlsfx
+ controlsfx
+ 8.0.6_20
+
+
+
+ de.jensd
+ fontawesomefx
+ 8.0.0
+
+
+
+ eu.hansolo.enzo
+ Enzo
+ 0.1.5
+
\ No newline at end of file
diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java
index ee0b27f092..c266930ea3 100644
--- a/gui/src/main/java/io/bitsquare/app/BitsquareApp.java
+++ b/gui/src/main/java/io/bitsquare/app/BitsquareApp.java
@@ -22,22 +22,17 @@ import io.bitsquare.gui.common.view.CachingViewLoader;
import io.bitsquare.gui.common.view.View;
import io.bitsquare.gui.common.view.ViewLoader;
import io.bitsquare.gui.common.view.guice.InjectorViewFactory;
-import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.main.MainView;
import io.bitsquare.gui.main.debug.DebugView;
import io.bitsquare.gui.util.ImageUtil;
-import io.bitsquare.storage.FileManager;
import io.bitsquare.util.Utilities;
import org.bitcoinj.utils.Threading;
-import com.google.common.base.Throwables;
-
import com.google.inject.Guice;
import com.google.inject.Injector;
import java.io.IOException;
-import java.io.InvalidObjectException;
import javafx.application.Application;
import javafx.application.Platform;
@@ -48,15 +43,17 @@ import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
-import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import ch.qos.logback.classic.Logger;
+import com.vinumeris.crashfx.CrashFX;
+import com.vinumeris.crashfx.CrashWindow;
import org.springframework.core.env.Environment;
import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY;
public class BitsquareApp extends Application {
- private static final Logger log = LoggerFactory.getLogger(BitsquareApp.class);
+ private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class);
private static Environment env;
@@ -72,26 +69,25 @@ public class BitsquareApp extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
this.primaryStage = primaryStage;
-
- log.trace("BitsquareApp.start");
try {
+ log.trace("BitsquareApp.start");
+
+ // Set user thread for callbacks from backend threads
Threading.USER_THREAD = Platform::runLater;
+ // Use CrashFX for report crash logs
+ /* CrashFX.setup("Bitsquare/" + Version.VERSION,
+ Paths.get(env.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY), "crashes"),
+ URI.create("http://188.226.179.109/crashfx/upload"));*/
+ // Server not setup yet, so we use client side only support
+ CrashFX.setup();
+
+ // Guice
bitsquareAppModule = new BitsquareAppModule(env, primaryStage);
injector = Guice.createInjector(bitsquareAppModule);
injector.getInstance(InjectorViewFactory.class).setInjector(injector);
- FileManager.setUncaughtExceptionHandler(
- (t, throwable) -> Platform.runLater(
- () -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable))
- )
- );
-
- Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) ->
- Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
-
// load the main view and create the main scene
- log.trace("viewLoader.load(MainView.class)");
CachingViewLoader viewLoader = injector.getInstance(CachingViewLoader.class);
View view = viewLoader.load(MainView.class);
@@ -100,9 +96,7 @@ public class BitsquareApp extends Application {
"/io/bitsquare/gui/bitsquare.css",
"/io/bitsquare/gui/images.css");
-
// configure the system tray
-
SystemTray.create(primaryStage, this::stop);
primaryStage.setOnCloseRequest(e -> {
e.consume();
@@ -119,9 +113,7 @@ public class BitsquareApp extends Application {
showDebugWindow();
});
-
// configure the primary stage
-
primaryStage.setTitle(env.getRequiredProperty(APP_NAME_KEY));
primaryStage.setScene(scene);
primaryStage.setMinWidth(750);
@@ -139,23 +131,17 @@ public class BitsquareApp extends Application {
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream(iconPath)));
-
// make the UI visible
-
- log.trace("primaryStage.show");
primaryStage.show();
//TODO just temp.
//showDebugWindow();
} catch (Throwable t) {
- if (t instanceof InvalidObjectException) {
- Popups.openErrorPopup("There is a problem with different version of persisted objects. " +
- "Please delete the db directory inside the app directory.");
- }
- log.error(t.toString());
+ CrashWindow.open(t);
}
}
+ //TODO just temp.
private void showDebugWindow() {
ViewLoader viewLoader = injector.getInstance(ViewLoader.class);
View debugView = viewLoader.load(DebugView.class);
diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareAppEnvironment.java b/gui/src/main/java/io/bitsquare/app/BitsquareAppEnvironment.java
index 815740a3f9..1887e66433 100644
--- a/gui/src/main/java/io/bitsquare/app/BitsquareAppEnvironment.java
+++ b/gui/src/main/java/io/bitsquare/app/BitsquareAppEnvironment.java
@@ -53,7 +53,7 @@ public class BitsquareAppEnvironment extends BitsquareEnvironment {
setProperty(APP_NAME_KEY, appName);
setProperty(UserAgent.NAME_KEY, appName);
- setProperty(UserAgent.VERSION_KEY, BitsquareAppMain.getVersion());
+ setProperty(UserAgent.VERSION_KEY, Version.VERSION);
setProperty(WalletService.DIR_KEY, appDataDir);
setProperty(WalletService.PREFIX_KEY, appName);
diff --git a/gui/src/main/java/io/bitsquare/app/BitsquareAppMain.java b/gui/src/main/java/io/bitsquare/app/BitsquareAppMain.java
index 1c5c33685d..4caeb80294 100644
--- a/gui/src/main/java/io/bitsquare/app/BitsquareAppMain.java
+++ b/gui/src/main/java/io/bitsquare/app/BitsquareAppMain.java
@@ -47,12 +47,6 @@ import static java.util.Arrays.asList;
public class BitsquareAppMain extends BitsquareExecutable {
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
- private static final String VERSION = "0.1";
-
- public static String getVersion() {
- return VERSION + "." + UpdateProcess.getBuildVersion();
- }
-
public static void main(String[] args) throws Exception {
// We don't want to do the full argument parsing here as that might easily change in update versions
// So we only handle the absolute minimum which is APP_NAME, APP_DATA_DIR_KEY and USER_DATA_DIR
@@ -76,6 +70,8 @@ public class BitsquareAppMain extends BitsquareExecutable {
BitsquareAppEnvironment bitsquareEnvironment = new BitsquareAppEnvironment(options);
String updatesDirectory = bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY);
+ Logging.setup(Paths.get(bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY), "bitsquare").toString());
+
// app dir need to be setup before UpdateFX bootstrap
initAppDir(updatesDirectory);
diff --git a/gui/src/main/java/io/bitsquare/app/UpdateProcess.java b/gui/src/main/java/io/bitsquare/app/UpdateProcess.java
index bcf1e87ce7..2189e83999 100644
--- a/gui/src/main/java/io/bitsquare/app/UpdateProcess.java
+++ b/gui/src/main/java/io/bitsquare/app/UpdateProcess.java
@@ -47,18 +47,11 @@ import rx.subjects.Subject;
public class UpdateProcess {
private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class);
- // Edit version for updateFX
- private static final int BUILD_VERSION = 3;
-
private static final List UPDATE_SIGNING_KEYS = Crypto.decode("0296CFF54A8B1611499D4C1024E654140AFBB58C505FE4BB7C847B4F4A7C683DF6");
private static final String UPDATES_BASE_URL = "http://bitsquare.io/updateFX/";
private static final int UPDATE_SIGNING_THRESHOLD = 1;
private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class);
- public static int getBuildVersion() {
- return BUILD_VERSION;
- }
-
private final Environment environment;
public enum State {
@@ -92,7 +85,7 @@ public class UpdateProcess {
}
public void init() {
- log.info("UpdateFX current version " + BUILD_VERSION);
+ log.info("UpdateFX current version " + Version.PATCH_VERSION);
// process.timeout() will cause an error state back but we don't want to break startup in case of an timeout
timeoutTimer = GUIUtil.setTimeout(10000, animationTimer -> {
@@ -101,9 +94,9 @@ public class UpdateProcess {
});
timeoutTimer.start();
- String agent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + BitsquareAppMain.getVersion();
+ String agent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + Version.VERSION;
Path dataDirPath = new File(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)).toPath();
- Updater updater = new Updater(UPDATES_BASE_URL, agent, BUILD_VERSION, dataDirPath, ROOT_CLASS_PATH,
+ Updater updater = new Updater(UPDATES_BASE_URL, agent, Version.PATCH_VERSION, dataDirPath, ROOT_CLASS_PATH,
UPDATE_SIGNING_KEYS, UPDATE_SIGNING_THRESHOLD) {
@Override
protected void updateProgress(long workDone, long max) {
@@ -125,14 +118,14 @@ public class UpdateProcess {
log.info("One liner: {}", summary.descriptions.get(0).getOneLiner());
log.info("{}", summary.descriptions.get(0).getDescription());
}
- if (summary.highestVersion > BUILD_VERSION) {
+ if (summary.highestVersion > Version.PATCH_VERSION) {
log.info("UPDATE_AVAILABLE");
state.set(State.UPDATE_AVAILABLE);
// We stop the timeout and treat it not completed.
// The user should click the restart button manually if there are updates available.
timeoutTimer.stop();
}
- else if (summary.highestVersion == BUILD_VERSION) {
+ else if (summary.highestVersion == Version.PATCH_VERSION) {
log.info("UP_TO_DATE");
state.set(State.UP_TO_DATE);
timeoutTimer.stop();
diff --git a/gui/src/main/java/io/bitsquare/gui/components/Popups.java b/gui/src/main/java/io/bitsquare/gui/components/Popups.java
index bdd73d3c55..6bfe84ad1d 100644
--- a/gui/src/main/java/io/bitsquare/gui/components/Popups.java
+++ b/gui/src/main/java/io/bitsquare/gui/components/Popups.java
@@ -20,14 +20,9 @@ package io.bitsquare.gui.components;
import io.bitsquare.gui.OverlayManager;
import io.bitsquare.locale.BSResources;
-import org.bitcoinj.store.BlockStoreException;
-
-import com.google.common.base.Throwables;
-
import java.util.ArrayList;
import java.util.List;
-import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.stage.Stage;
@@ -213,33 +208,6 @@ public class Popups {
removeBlurContent();
}
- // Support handling of uncaught exception from any thread (also non gui thread)
- public static void handleUncaughtExceptions(Throwable throwable) {
- // while dev
- log.error(throwable.getMessage());
- log.error(throwable.toString());
- throwable.printStackTrace();
-
- Runnable runnable = () -> {
- if (Throwables.getRootCause(throwable) instanceof BlockStoreException) {
- Popups.openErrorPopup("Error", "Application already running",
- "This application is already running and cannot be started twice.\n\n " +
- "Check your system tray to reopen the window of the running application.");
- Platform.exit();
- }
- else {
- Popups.openExceptionPopup(throwable, "Exception", "A critical error has occurred.",
- "Please copy the exception details and open a bug report at:\n " +
- "https://github.com/bitsquare/bitsquare/issues.");
- Platform.exit();
- }
- };
-
- if (Platform.isFxApplicationThread())
- runnable.run();
- else
- Platform.runLater(runnable);
- }
// custom
public static void openInsufficientMoneyPopup() {
diff --git a/gui/src/main/java/io/bitsquare/gui/main/offer/offerbook/OfferBookView.java b/gui/src/main/java/io/bitsquare/gui/main/offer/offerbook/OfferBookView.java
index 54e378e11b..3a7a09b9d7 100644
--- a/gui/src/main/java/io/bitsquare/gui/main/offer/offerbook/OfferBookView.java
+++ b/gui/src/main/java/io/bitsquare/gui/main/offer/offerbook/OfferBookView.java
@@ -163,7 +163,7 @@ public class OfferBookView extends ActivatableViewAndModel
-
- .bitsquare/bitsquare.log
- false
-
- .bitsquare_logs/bitsquare_%i.log
- 1
- 10
-
-
-
- 1MB
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n
-
-
-
-
diff --git a/pom.xml b/pom.xml
index fc19698457..1cae858766 100755
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.bitsquare
parent
pom
- 0.1.4-SNAPSHOT
+ 0.2.1-SNAPSHOT
The decentralized bitcoin exchange
https://bitsquare.io