Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanni committed May 28, 2017
1 parent 6fb7d56 commit 0c74d7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/org/helioviewer/jhv/base/logging/Log.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package org.helioviewer.jhv.base.logging;

import org.helioviewer.jhv.base.time.TimeUtils;

public class Log {

private static String format(String s) {
return TimeUtils.format(System.currentTimeMillis()) + " [" + Thread.currentThread().getName() + "] " + s;
}

public static void warn(Object obj) {
System.err.println(obj.toString());
System.err.println(format("WARN " + obj.toString()));
}

public static void error(Object obj) {
System.err.println(obj.toString());
System.err.println(format("ERROR " + obj.toString()));
}

public static void error(Object obj, Throwable error) {
System.err.println(obj.toString() + error.toString());
System.err.println(format("ERROR " + obj.toString() + error.toString()));
}

public static void debug(Object obj) {
System.out.println(obj.toString());
System.out.println(format("DEBUG " + obj.toString()));
}

}
2 changes: 1 addition & 1 deletion src/org/helioviewer/jhv/io/DataSourcesTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void run() {
JSONObject json = JSONUtils.getJSONStream(new DownloadStream(url).getInput());
schema.validate(json);
} catch (Exception e) {
Log.error(e);
Log.error(url + " : " + e);
}
}

Expand Down

0 comments on commit 0c74d7d

Please sign in to comment.