changeset 1030:8e6364a2a47f

Logging jnlp file into console * netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java: isn ow html-like escaping lesser then and greater then chars * netx/net/sourceforge/nanoxml/XMLElement.java: instead of reprinting jnlp file to stdout, the line is gathered and logged via standard logge
author Jiri Vanek <jvanek@redhat.com>
date Wed, 19 Nov 2014 18:33:56 +0100
parents e8dcd9718b5b
children 6a89cef74ddf
files ChangeLog netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java netx/net/sourceforge/nanoxml/XMLElement.java
diffstat 3 files changed, 32 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Nov 19 09:56:48 2014 -0500
+++ b/ChangeLog	Wed Nov 19 18:33:56 2014 +0100
@@ -1,3 +1,11 @@
+2014-11-19  Jiri Vanek  <jvanek@redhat.com>
+
+	Logging jnlp file into console
+	* netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java: is
+	now html-like escaping lesser then and greater then chars
+	* netx/net/sourceforge/nanoxml/XMLElement.java: instead of reprinting jnlp
+	file to stdout, the line is gathered and logged via standard logger
+
 2014-11-19  Jie Kang  <jkang@redhat.com>
 
 	Fixed PluginMessage dates to use localized date from icedteanp-side.
--- a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java	Wed Nov 19 09:56:48 2014 -0500
+++ b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPaneModel.java	Wed Nov 19 18:33:56 2014 +0100
@@ -205,6 +205,8 @@
             }
             String line = (createLine(messageWithHeader));
             if (mark) {
+                line = line.replaceAll("<", "&lt;");
+                line = line.replaceAll(">", "&gt;");
                 line = line.replaceAll("\n", "<br/>\n");
                 line = line.replaceAll("  ", "&nbsp; ");//small trick, html is reducting row of spaces to single space. This handles it and stimm allow line wrap
                 line = line.replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
--- a/netx/net/sourceforge/nanoxml/XMLElement.java	Wed Nov 19 09:56:48 2014 -0500
+++ b/netx/net/sourceforge/nanoxml/XMLElement.java	Wed Nov 19 18:33:56 2014 +0100
@@ -1157,9 +1157,9 @@
      *             filtered xml file.
      */
     public void sanitizeInput(Reader isr, OutputStream pout) {
+        StringBuilder line = new StringBuilder();
         try {
             PrintStream out = new PrintStream(pout);
-
             this.sanitizeCharReadTooMuch = '\0';
             this.reader = isr;
             this.parserLineNr = 0;
@@ -1192,14 +1192,12 @@
                     // what's in the buffer
                     out.print(ch);
                     out.flush();
-                    if (JNLPRuntime.isDebug()) {
-                        if (ch == 10) {
-                            OutputController.getLogger().printOutLn("");
-                            OutputController.getLogger().printOut("line: " + newline + " ");
-                            newline++;
-                        } else {
-                            OutputController.getLogger().printOut(ch+"");
-                        }
+                    if (ch == 10) {
+                        OutputController.getLogger().log(line.toString());
+                        line = new StringBuilder("line: " + newline + " ");
+                        newline++;
+                    } else {
+                        line.append(ch);
                     }
                     break;
                 } else if (i == 10) {
@@ -1224,44 +1222,41 @@
                             out.print('!');
                             out.print('-');
                             this.sanitizeCharReadTooMuch = ch;
-                            if (JNLPRuntime.isDebug()) {
-                                OutputController.getLogger().printOut("<");
-                                OutputController.getLogger().printOut("!");
-                                OutputController.getLogger().printOut("-");
-                            }
+                            line.append("<");
+                            line.append("!");
+                            line.append("-");
                         }
                     } else {
                         out.print('<');
                         out.print('!');
                         this.sanitizeCharReadTooMuch = ch;
-                        if (JNLPRuntime.isDebug()) {
-                              OutputController.getLogger().printOut("<");
-                              OutputController.getLogger().printOut("!");
-                        }
+                        line.append("<");
+                        line.append("!");
                     }
                 }
                 // Otherwise we haven't hit a comment, and we should write ch.
                 else {
                     out.print(ch);
-                    if (JNLPRuntime.isDebug()) {
-                        if (ch == 10) {
-                            OutputController.getLogger().printOutLn("");
-                            OutputController.getLogger().printOut("line: " + newline + " ");
-                            newline++;
-                        } else {
-                            OutputController.getLogger().printOut(ch+"");
-                        }
+                    if (ch == 10) {
+                        OutputController.getLogger().log(line.toString());
+                        line = new StringBuilder("line: " + newline + " ");
+                        newline++;
+                    } else {
+                        line.append(ch);
                     }
                 }
                 prev = next;
             }
-
             out.close();
             isr.close();
         } catch (Exception e) {
             // Print the stack trace here -- xml.parseFromReader() will
             // throw the ParseException if something goes wrong.
             OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e);
+        } finally {
+            OutputController.getLogger().log("");//force new line in all cases
+            OutputController.getLogger().log(line.toString()); //flush remaining line
+
         }
     }
 }