time in log from remote server
[nikiroo-utils.git] / src / be / nikiroo / fanfix / library / RemoteLibraryServer.java
index 015fb7bf33c9c2beb79a81173b1f02f180f48db9..f88b25ae5a3d335938fba59b0c3a24fea6afb8f9 100644 (file)
@@ -142,9 +142,15 @@ public class RemoteLibraryServer extends ServerObject {
                for (Object arg : args) {
                        trace += arg + " ";
                }
-               System.out.println(trace);
-
-               Object rep = doRequest(action, command, args, rw, whitelist);
+               long now = System.currentTimeMillis();
+               System.out.println(StringUtils.fromTime(now) + ": " + trace);
+
+               Object rep = null;
+               try {
+                       rep = doRequest(action, command, args, rw, whitelist);
+               } catch (IOException e) {
+                       rep = new RemoteLibraryException(e);
+               }
 
                commands.put(id, command);
                wls.put(id, wl);
@@ -175,9 +181,12 @@ public class RemoteLibraryServer extends ServerObject {
 
                String rec = StringUtils.formatNumber(bytesReceived) + "b";
                String sent = StringUtils.formatNumber(bytesSent) + "b";
-               System.out.println(String.format("%s[>%s]: (%s sent, %s rec) in %d ms",
-                               display(whitelist, rw), commands.get(id), sent, rec,
-                               times.get(id)));
+               long now = System.currentTimeMillis();
+               System.out.println(StringUtils.fromTime(now)
+                               + ": "
+                               + String.format("%s[>%s]: (%s sent, %s rec) in %d ms",
+                                               display(whitelist, rw), commands.get(id), sent, rec,
+                                               times.get(id)));
 
                commands.remove(id);
                times.remove(id);
@@ -342,7 +351,9 @@ public class RemoteLibraryServer extends ServerObject {
        @Override
        protected void onError(Exception e) {
                if (e instanceof SSLException) {
-                       System.out.println("[Client connection refused (bad key)]");
+                       long now = System.currentTimeMillis();
+                       System.out.println(StringUtils.fromTime(now) + ": "
+                                       + "[Client connection refused (bad key)]");
                } else {
                        getTraceHandler().error(e);
                }