time in log from remote server
[fanfix.git] / src / be / nikiroo / fanfix / library / RemoteLibraryServer.java
index ada467311d1e2d77801b6a7df379ee0272dad3f4..f88b25ae5a3d335938fba59b0c3a24fea6afb8f9 100644 (file)
@@ -142,14 +142,14 @@ public class RemoteLibraryServer extends ServerObject {
                for (Object arg : args) {
                        trace += arg + " ";
                }
-               System.out.println(trace);
+               long now = System.currentTimeMillis();
+               System.out.println(StringUtils.fromTime(now) + ": " + trace);
 
                Object rep = null;
-               Exception oops = null;
                try {
                        rep = doRequest(action, command, args, rw, whitelist);
-               } catch (Exception e) {
-                       oops = e;
+               } catch (IOException e) {
+                       rep = new RemoteLibraryException(e);
                }
 
                commands.put(id, command);
@@ -157,10 +157,6 @@ public class RemoteLibraryServer extends ServerObject {
                rws.put(id, rw);
                times.put(id, (new Date().getTime() - start));
 
-               if (oops != null) {
-                       throw oops;
-               }
-
                return rep;
        }
 
@@ -185,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);
@@ -352,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);
                }