From 005d9ee999b19e6a079625aeb5efcf9f2636c2a7 Mon Sep 17 00:00:00 2001
From: Joel Martin <github@martintribe.org>
Date: Thu, 23 Sep 2010 08:17:00 -0500
Subject: [PATCH] Misc cleanup: debug logging, record filename, etc.

- include/canvas.js: When 'debug' logging, show browser detection
  values.
- test/canvas.html: Only restore the canvas to it's starting state if
  the logging level is not 'debug'.
- wsproxy.py: Append the session number to the record filename so that
  multiple sessions don't stomp on each other.
---
 include/canvas.js | 7 ++++++-
 tests/canvas.html | 6 ++++--
 utils/wsproxy.py  | 5 +++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/canvas.js b/include/canvas.js
index 954f5b5..3b9cde5 100644
--- a/include/canvas.js
+++ b/include/canvas.js
@@ -89,7 +89,7 @@ function constructor() {
     Util.Debug(">> Canvas.init");
 
     var c, ctx, imgTest, tval, i, curDat, curSave,
-        has_imageData = false;
+        has_imageData = false, UE = Util.Engine;
 
     if (! conf.target) { throw("target must be set"); }
 
@@ -104,6 +104,11 @@ function constructor() {
     if (! conf.ctx) { conf.ctx = c.getContext('2d'); }
     ctx = conf.ctx;
 
+    if (UE.gecko) { Util.Debug("Browser: gecko " + UE.gecko); }
+    if (UE.webkit) { Util.Debug("Browser: webkit " + UE.webkit); }
+    if (UE.trident) { Util.Debug("Browser: webkit " + UE.trident); }
+    if (UE.presto) { Util.Debug("Browser: webkit " + UE.presto); }
+
     that.clear();
 
     /*
diff --git a/tests/canvas.html b/tests/canvas.html
index 87e7781..f271953 100644
--- a/tests/canvas.html
+++ b/tests/canvas.html
@@ -104,8 +104,10 @@
             message("prefer Canvas ops: " + time2 + "ms total, " +
                     (time2 / iterations) + "ms per frame");
 
-            canvas.resize(start_width, start_height, true);
-            test_functions();
+            if (Util.get_logging() !== 'debug') {
+                canvas.resize(start_width, start_height, true);
+                test_functions();
+            }
             $('startButton').disabled = false;
             $('startButton').value = "Do Performance Test";
         }
diff --git a/utils/wsproxy.py b/utils/wsproxy.py
index 0d1a68f..2615c3c 100755
--- a/utils/wsproxy.py
+++ b/utils/wsproxy.py
@@ -105,7 +105,8 @@ def proxy_handler(client):
 
     if settings['record']:
         handler_msg("opening record file: %s" % settings['record'])
-        rec = open(settings['record'], 'w+')
+        rec = open("%s.%s" % (settings['record'],
+                              settings['handler_id']), 'w+')
         rec.write("var VNC_frame_data = [\n")
 
     handler_msg("connecting to: %s:%s" % (target_host, target_port))
@@ -131,7 +132,7 @@ if __name__ == '__main__':
     parser.add_option("--verbose", "-v", action="store_true",
             help="verbose messages and per frame traffic")
     parser.add_option("--record",
-            help="record session to a file", metavar="FILE")
+            help="record sessions to FILE.[session_number]", metavar="FILE")
     parser.add_option("--foreground", "-f",
             dest="daemon", default=True, action="store_false",
             help="stay in foreground, do not daemonize")
-- 
2.18.1