Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Apr 23, 2016
1 parent f700c42 commit b4edbe2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions common/src/main/java/io/bitsquare/app/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Log {
private static SizeBasedTriggeringPolicy triggeringPolicy;
private static Logger logbackLogger;

public static void setup(String fileName, boolean useDetailedLogging) {
public static void setup(String fileName) {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

RollingFileAppender appender = new RollingFileAppender();
Expand Down Expand Up @@ -60,8 +60,8 @@ public static void setup(String fileName, boolean useDetailedLogging) {
appender.start();

logbackLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.WARN);
logbackLogger.addAppender(appender);
logbackLogger.setLevel(Level.INFO);

// log errors in separate file
// not working as expected still.... damn logback...
Expand All @@ -80,6 +80,10 @@ public static void setup(String fileName, boolean useDetailedLogging) {
logbackLogger.addAppender(errorAppender);*/
}

public static void setLevel(boolean useDetailedLogging) {
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.WARN);
}

public static void traceCall() {
if (LoggerFactory.getLogger(Log.class).isTraceEnabled()) {
StackTraceElement stackTraceElement = new Throwable().getStackTrace()[1];
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/io/bitsquare/trade/offer/Offer.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public Fiat getPrice() {
return null;
}
} else {
log.warn("We don't have a market price.\n" +
log.debug("We don't have a market price.\n" +
"That case could only happen if you don't have a price feed.");
return null;
}
Expand Down
4 changes: 3 additions & 1 deletion gui/src/main/java/io/bitsquare/app/BitsquareApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ public static void setEnvironment(Environment env) {
@Override
public void start(Stage primaryStage) throws IOException {
String logPath = Paths.get(env.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY), "bitsquare").toString();
Log.setup(logPath, !IS_RELEASE_VERSION);

Log.setup(logPath);
log.info("Log files under: " + logPath);
Version.printVersion();
Utilities.printSysInfo();
Log.setLevel(!IS_RELEASE_VERSION);

UserThread.setExecutor(Platform::runLater);
UserThread.setTimerClass(UITimer.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,12 @@ public void handleConnectionException(Throwable e) {
} else {
// TODO sometimes we get StreamCorruptedException, OptionalDataException, IllegalStateException
closeConnectionReason = CloseConnectionReason.UNKNOWN_EXCEPTION;
log.warn("Unknown reason for exception at socket {}\n\tconnection={}\n\tException=",
socket.toString(), this, e.toString());
log.warn("Unknown reason for exception at socket {}\n\t" +
"connection={}\n\t" +
"Exception=",
socket.toString(),
this,
e.toString());
e.printStackTrace();
}

Expand Down

0 comments on commit b4edbe2

Please sign in to comment.