From 0c74d7dcdaf00f18d73c4444043b7fa5ea9e18df Mon Sep 17 00:00:00 2001 From: Bogdan Nicula Date: Sun, 28 May 2017 20:59:48 +0200 Subject: [PATCH] Improve logging --- src/org/helioviewer/jhv/base/logging/Log.java | 14 ++++++++++---- src/org/helioviewer/jhv/io/DataSourcesTask.java | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/org/helioviewer/jhv/base/logging/Log.java b/src/org/helioviewer/jhv/base/logging/Log.java index 93e2efa..0933558 100644 --- a/src/org/helioviewer/jhv/base/logging/Log.java +++ b/src/org/helioviewer/jhv/base/logging/Log.java @@ -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())); } } diff --git a/src/org/helioviewer/jhv/io/DataSourcesTask.java b/src/org/helioviewer/jhv/io/DataSourcesTask.java index 6475375..3f36577 100644 --- a/src/org/helioviewer/jhv/io/DataSourcesTask.java +++ b/src/org/helioviewer/jhv/io/DataSourcesTask.java @@ -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); } }