/hg/icedtea-web: 2 new changesets

jvanek at icedtea.classpath.org jvanek at icedtea.classpath.org
Fri Nov 29 03:08:18 PST 2013


changeset 3645d1e20a00 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=3645d1e20a00
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Nov 29 11:44:11 2013 +0100

	Enabled file logging in plugin, user enabled to choose logs dir


changeset b8f6c7c54e1c in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=b8f6c7c54e1c
author: Jiri Vanek <jvanek at redhat.com>
date: Fri Nov 29 12:14:43 2013 +0100

	Pipes moved into XDG_RUNTIME_DIR


diffstat:

 ChangeLog                                                        |   41 +++
 netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java       |   54 ++++-
 netx/net/sourceforge/jnlp/resources/Messages.properties          |    4 +-
 netx/net/sourceforge/jnlp/util/logging/FileLog.java              |   23 +-
 plugin/icedteanp/IcedTeaNPPlugin.cc                              |  110 ++++-----
 plugin/icedteanp/IcedTeaNPPlugin.h                               |    3 +
 plugin/icedteanp/IcedTeaParseProperties.cc                       |   45 ++++-
 plugin/icedteanp/IcedTeaParseProperties.h                        |    5 +-
 plugin/icedteanp/IcedTeaPluginUtils.cc                           |   97 ++++++++-
 plugin/icedteanp/IcedTeaPluginUtils.h                            |   86 ++++++-
 plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java |    2 +-
 tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc                   |   12 +
 12 files changed, 397 insertions(+), 85 deletions(-)

diffs (truncated from 1043 to 500 lines):

diff -r 72f45c87b008 -r b8f6c7c54e1c ChangeLog
--- a/ChangeLog	Wed Nov 27 16:37:38 2013 -0500
+++ b/ChangeLog	Fri Nov 29 12:14:43 2013 +0100
@@ -1,3 +1,44 @@
+2013-11-29  Jiri Vanek  <jvanek at redhat.com>
+
+	Pipes moved into XDG_RUNTIME_DIR
+	* plugin/icedteanp/IcedTeaNPPlugin.cc: (initialize_data_directory) logic
+	responsible for tmp dir path moved into (getTmpPath) and (data_directory)
+	initialized from (getRuntimePath) rather.
+	*  plugin/icedteanp/IcedTeaPluginUtils.cc: (getTmpPath) new function,
+	provides path to tmp dir. (getRuntimePath) new function resolving 
+	XDG_RUNTIME_DIR value, returning (getTmpPath) as fallback.
+	* plugin/icedteanp/IcedTeaPluginUtils.h: declared new two methods.
+
+2013-11-29  Jiri Vanek  <jvanek at redhat.com>
+
+	Enabled file logging in plugin, user enabled to choose logs dir.
+	* netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java: added
+	text-field to show/edit logs' destination. Added reset to default button.
+	* netx/net/sourceforge/jnlp/resources/Messages.propertie: added proper
+	keys for new controls (CPFilesLogsDestDir) and (CPFilesLogsDestDirResert).
+	(DPEnableLogging) changed to "Enable debugging", as it is better.
+	* netx/net/sourceforge/jnlp/util/logging/FileLog.java: Filename of logs
+	changed to be human readable and to distinguish between c/java
+	* plugin/icedteanp/IcedTeaNPPlugin.cc: made aware of console (plugin_debug_to_console)
+	added stream to log into file (plugin_file_log) and holder of name (plugin_file_log_name)
+	Added various new lines to end of erorr/debug messages. Stream flushed,
+	not closed on plugin shutdown.
+	* plugin/icedteanp/IcedTeaNPPlugin.h: extern above three fields.
+	* plugin/icedteanp/IcedTeaParseProperties.cc: added functionality to provide
+	set or default log dir (get_log_dir), added (is_java_console_enabled) 
+	to determine logging to console
+	* plugin/icedteanp/IcedTeaParseProperties.h: used glib.h, declared above functions
+	* plugin/icedteanp/IcedTeaPluginUtils.cc: added (initFileLog) function to open 
+	correctly named, in proper palce and with correct permissions file for logging
+	(generateLogFileName) generate human readable file name, as java do.
+	(printDebugStatus)  to debug status of logging
+	* plugin/icedteanp/IcedTeaPluginUtils.h: headers generated once, and reused
+	declared above functions.
+	* plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java:
+	commented out useless "woken" debug message
+	* tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc: made plugin_debug_to_console
+	aware.	
+
 2013-11-27  Andrew Azores  <aazores at redhat.com>
 
 	Made JNLPClassLoaderDeadlock reproducer more reliable
diff -r 72f45c87b008 -r b8f6c7c54e1c netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java	Wed Nov 27 16:37:38 2013 -0500
+++ b/netx/net/sourceforge/jnlp/controlpanel/DebuggingPanel.java	Fri Nov 29 12:14:43 2013 +0100
@@ -23,13 +23,20 @@
 import java.awt.FlowLayout;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import javax.swing.Box;
+import javax.swing.JButton;
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import net.sourceforge.jnlp.config.Defaults;
 import net.sourceforge.jnlp.config.DeploymentConfiguration;
 import net.sourceforge.jnlp.runtime.Translator;
 import net.sourceforge.jnlp.util.logging.LogConfig;
@@ -74,7 +81,41 @@
     private void addComponents() {
         GridBagConstraints c = new GridBagConstraints();
 
-        JLabel debuggingDescription = new JLabel("<html>" + Translator.R("CPDebuggingDescription") + "<hr /><br /></html>");
+
+        final JLabel debuggingDescription = new JLabel("<html>" + Translator.R("CPDebuggingDescription") + "<hr /><br /></html>");
+        final JLabel logsDestinationTitle = new JLabel(Translator.R("CPFilesLogsDestDir")+": ");
+        final JTextField logsDestination = new JTextField(config.getProperty(DeploymentConfiguration.KEY_USER_LOG_DIR));
+        logsDestination.getDocument().addDocumentListener(new DocumentListener() {
+
+
+            @Override
+            public void insertUpdate(DocumentEvent e) {
+                 save();
+            }
+
+            @Override
+            public void removeUpdate(DocumentEvent e) {
+                 save();
+            }
+
+            @Override
+            public void changedUpdate(DocumentEvent e) {
+                save();
+
+            }
+
+            private void save() {
+                config.setProperty(DeploymentConfiguration.KEY_USER_LOG_DIR, logsDestination.getText());
+            }
+        });
+        final JButton logsDestinationReset = new JButton(Translator.R("CPFilesLogsDestDirResert"));
+        logsDestinationReset.addActionListener(new ActionListener() {
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                logsDestination.setText(Defaults.getDefaults().get(DeploymentConfiguration.KEY_USER_LOG_DIR).getDefaultValue());
+            }
+        });
 
         JCheckBox[] debuggingOptions = { 
                 new JCheckBox(Translator.R("DPEnableLogging")),
@@ -130,8 +171,17 @@
             debuggingOptions[i].addItemListener(this);
             add(debuggingOptions[i], c);
 
+              if (i == 2) {
+                 c.gridx++;
+                add(logsDestinationTitle, c);
+                c.gridx++;
+                add(logsDestination, c);
+                c.gridx++;
+                add(logsDestinationReset, c);
+                c.gridx-=3;
+            }
+        }
 
-        }
 
         for (int j = 0; j < javaConsoleItems.length; j++) {
             consoleComboBox.addItem(javaConsoleItems[j]);
diff -r 72f45c87b008 -r b8f6c7c54e1c netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties	Wed Nov 27 16:37:38 2013 -0500
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties	Fri Nov 29 12:14:43 2013 +0100
@@ -402,11 +402,13 @@
 
 # Control Panel - DebugginPanel
 CPDebuggingPossibilites=Logging outputs
-DPEnableLogging=Enable logging
+DPEnableLogging=Enable debugging
 DPEnableLoggingHint=When this switch is on,  then also debug messages are logged. Same as -verbose or ICEDTEAPLUGIN_DEBUG=true
 DPEnableHeaders=Enable headers
 DPEnableHeadersHint=When this switch is on, each logged message have header with additional information like user, place in code  and time
 DPEnableFile=Enable logging to file
+CPFilesLogsDestDir=File logs directory
+CPFilesLogsDestDirResert=Reset to default
 DPEnableFileHint=output messages will be saved to file in your {0}  directory
 DPEnableStds=Enable logging to standard outputs
 DPEnableStdsHint=messages will be printed to standard outputs
diff -r 72f45c87b008 -r b8f6c7c54e1c netx/net/sourceforge/jnlp/util/logging/FileLog.java
--- a/netx/net/sourceforge/jnlp/util/logging/FileLog.java	Wed Nov 27 16:37:38 2013 -0500
+++ b/netx/net/sourceforge/jnlp/util/logging/FileLog.java	Fri Nov 29 12:14:43 2013 +0100
@@ -38,6 +38,8 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.logging.FileHandler;
 import java.util.logging.Formatter;
 import java.util.logging.Level;
@@ -50,17 +52,20 @@
  *
  */
 public final class FileLog implements SingleStreamLogger {
+    private static SimpleDateFormat fileLogNameFormatter =  new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.S");
+    /**"Tue Nov 19 09:43:50 CET 2013"*/
+    private static SimpleDateFormat pluginSharedFormatter =  new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy");
 
     private final Logger impl;
     private final FileHandler fh;
     private static final String defaultloggerName = "IcedTea-Web file-logger";
 
     public FileLog() {
-        this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", false);
+        this(false);
     }
     
      public FileLog(boolean append) {
-        this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-" + java.lang.System.currentTimeMillis() + ".log", append);
+        this(defaultloggerName, LogConfig.getLogConfig().getIcedteaLogDir() + "itw-javantx-" + getStamp() + ".log", append);
     }
 
 
@@ -104,4 +109,18 @@
     public void close(){
         fh.close();
     }
+
+    private static String getStamp() {
+        return fileLogNameFormatter.format(new Date());
+    }
+
+    public static SimpleDateFormat getFileLogNameFormatter() {
+        return fileLogNameFormatter;
+    }
+
+    public static SimpleDateFormat getPluginSharedFormatter() {
+        return pluginSharedFormatter;
+    }
+
+    
 }
diff -r 72f45c87b008 -r b8f6c7c54e1c plugin/icedteanp/IcedTeaNPPlugin.cc
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Wed Nov 27 16:37:38 2013 -0500
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Fri Nov 29 12:14:43 2013 +0100
@@ -219,6 +219,10 @@
 bool plugin_debug_to_file = false ;
 bool plugin_debug_to_streams = true ;
 bool plugin_debug_to_system = false;
+bool plugin_debug_to_console = true;
+FILE *  plugin_file_log;
+std::string plugin_file_log_name;
+
 int plugin_debug_suspend = (getenv("ICEDTEAPLUGIN_DEBUG") != NULL) &&
         (strcmp(getenv("ICEDTEAPLUGIN_DEBUG"), "suspend") == 0);
 
@@ -330,7 +334,7 @@
 
   if (!instance)
   {
-      PLUGIN_ERROR ("Browser-provided instance pointer is NULL.");
+      PLUGIN_ERROR ("Browser-provided instance pointer is NULL.\n");
       return NPERR_INVALID_INSTANCE_ERROR;
   }
 
@@ -338,7 +342,7 @@
   ITNPPluginData* data = plugin_data_new ();
   if (data == NULL)
   {
-      PLUGIN_ERROR ("Failed to allocate plugin data.");
+      PLUGIN_ERROR ("Failed to allocate plugin data.\n");
       return NPERR_OUT_OF_MEMORY_ERROR;
     }
 
@@ -439,7 +443,7 @@
                                          data_directory.c_str(), getpid());
   if (!in_pipe_name)
     {
-      PLUGIN_ERROR ("Failed to create input pipe name.");
+      PLUGIN_ERROR ("Failed to create input pipe name.\n");
       np_error = NPERR_OUT_OF_MEMORY_ERROR;
       // If in_pipe_name is NULL then the g_free at
       // cleanup_in_pipe_name will simply return.
@@ -452,7 +456,7 @@
   PLUGIN_DEBUG ("ITNP_New: creating input fifo: %s\n", in_pipe_name);
   if (mkfifo (in_pipe_name, 0600) == -1 && errno != EEXIST)
     {
-      PLUGIN_ERROR ("Failed to create input pipe", strerror (errno));
+      PLUGIN_ERROR ("Failed to create input pipe\n", strerror (errno));
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_in_pipe_name;
     }
@@ -467,7 +471,7 @@
 
   if (!out_pipe_name)
     {
-      PLUGIN_ERROR ("Failed to create output pipe name.");
+      PLUGIN_ERROR ("Failed to create output pipe name.\n");
       np_error = NPERR_OUT_OF_MEMORY_ERROR;
       goto cleanup_out_pipe_name;
     }
@@ -478,7 +482,7 @@
   PLUGIN_DEBUG ("ITNP_New: creating output fifo: %s\n", out_pipe_name);
   if (mkfifo (out_pipe_name, 0600) == -1 && errno != EEXIST)
     {
-      PLUGIN_ERROR ("Failed to create output pipe", strerror (errno));
+      PLUGIN_ERROR ("Failed to create output pipe\n", strerror (errno));
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_out_pipe_name;
     }
@@ -500,13 +504,13 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR ("Failed to create output channel",
+          PLUGIN_ERROR ("Failed to create output channel, '%s'\n",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
         }
       else
-        PLUGIN_ERROR ("Failed to create output channel");
+        PLUGIN_ERROR ("Failed to create output channel\n");
 
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_out_to_appletviewer;
@@ -527,13 +531,13 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR ("Failed to create input channel",
+          PLUGIN_ERROR ("Failed to create input channel, '%s'\n",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
         }
       else
-        PLUGIN_ERROR ("Failed to create input channel");
+        PLUGIN_ERROR ("Failed to create input channel\n");
 
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_in_from_appletviewer;
@@ -549,7 +553,7 @@
 
   goto done;
 
-  // Free allocated data
+  // Free allocated data in case of error
 
  cleanup_in_watch_source:
   // Removing a source is harmless if it fails since it just means the
@@ -593,6 +597,7 @@
 
  done:
 
+  IcedTeaPluginUtilities::printDebugStatus();
   // Now other threads may re-enter.. unlock the mutex
   g_mutex_unlock(vm_start_mutex);
 
@@ -621,7 +626,7 @@
       }
       break;
     default:
-      PLUGIN_ERROR ("Unknown plugin value requested.");
+      PLUGIN_ERROR ("Unknown plugin value requested.\n");
       np_error = NPERR_GENERIC_ERROR;
       break;
     }
@@ -670,7 +675,7 @@
 
   if (instance == NULL)
     {
-      PLUGIN_ERROR ("Invalid instance.");
+      PLUGIN_ERROR ("Invalid instance.\n");
 
       return NPERR_INVALID_INSTANCE_ERROR;
     }
@@ -990,13 +995,13 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR ("Failed to read line from input channel",
+              PLUGIN_ERROR ("Failed to read line from input channel, %s\n",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
             }
           else
-            PLUGIN_ERROR ("Failed to read line from input channel");
+            PLUGIN_ERROR ("Failed to read line from input channel\n");
         } else
         {
           consume_message(message);
@@ -1329,13 +1334,13 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR ("Failed to spawn applet viewer",
+          PLUGIN_ERROR ("Failed to spawn applet viewer %s\n",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
         }
       else
-        PLUGIN_ERROR ("Failed to spawn applet viewer");
+        PLUGIN_ERROR ("Failed to spawn applet viewer\n");
       error = NPERR_GENERIC_ERROR;
     }
 
@@ -1409,13 +1414,13 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR ("Failed to spawn applet viewer",
+          PLUGIN_ERROR ("Failed to spawn applet viewer %s\n",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
         }
       else
-        PLUGIN_ERROR ("Failed to spawn applet viewer");
+        PLUGIN_ERROR ("Failed to spawn applet viewer\n");
       error = NPERR_GENERIC_ERROR;
     }
 
@@ -1540,13 +1545,13 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR ("Failed to write bytes to output channel",
+              PLUGIN_ERROR ("Failed to write bytes to output channel '%s' \n",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
             }
           else
-            PLUGIN_ERROR ("Failed to write bytes to output channel");
+            PLUGIN_ERROR ("Failed to write bytes to output channel for %s", newline_message);
         }
 
       if (g_io_channel_flush (out_to_appletviewer, &channel_error)
@@ -1554,18 +1559,18 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR ("Failed to flush bytes to output channel",
+              PLUGIN_ERROR ("Failed to flush bytes to output channel '%s'\n",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
             }
           else
-            PLUGIN_ERROR ("Failed to flush bytes to output channel");
+            PLUGIN_ERROR ("Failed to flush bytes to output channel for %s", newline_message);
         }
       g_free (newline_message);
       newline_message = NULL;
 
-      PLUGIN_DEBUG ("  PIPE: plugin wrote: %s\n", message);
+      PLUGIN_DEBUG ("  PIPE: plugin wrote(?): %s\n", message);
     }
 
   PLUGIN_DEBUG ("plugin_send_message_to_appletviewer return\n");
@@ -1621,13 +1626,13 @@
             {
               if (channel_error)
                 {
-                  PLUGIN_ERROR ("Failed to write shutdown message to"
-                                    " appletviewer", channel_error->message);
+                  PLUGIN_ERROR ("Failed to write shutdown message to "
+                                    " appletviewer, %s \n", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
                 }
               else
-                PLUGIN_ERROR ("Failed to write shutdown message to");
+                PLUGIN_ERROR ("Failed to write shutdown message to\n");
             }
 
           if (g_io_channel_flush (out_to_appletviewer, &channel_error)
@@ -1636,12 +1641,12 @@
               if (channel_error)
                 {
                   PLUGIN_ERROR ("Failed to write shutdown message to"
-                                    " appletviewer", channel_error->message);
+                                    " appletviewer %s \n", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
                 }
               else
-                PLUGIN_ERROR ("Failed to write shutdown message to");
+                PLUGIN_ERROR ("Failed to write shutdown message to\n");
             }
 
           if (g_io_channel_shutdown (out_to_appletviewer,
@@ -1651,12 +1656,12 @@
               if (channel_error)
                 {
                   PLUGIN_ERROR ("Failed to shut down appletviewer"
-                                    " output channel", channel_error->message);
+                                    " output channel %s \n", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
                 }
               else
-                PLUGIN_ERROR ("Failed to shut down appletviewer");
+                PLUGIN_ERROR ("Failed to shut down appletviewer\n");
             }
         }
 
@@ -1669,12 +1674,12 @@
               if (channel_error)
                 {
                   PLUGIN_ERROR ("Failed to shut down appletviewer"
-                                    " input channel", channel_error->message);
+                                    " input channel %s \n", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
                 }
               else
-                PLUGIN_ERROR ("Failed to shut down appletviewer");
+                PLUGIN_ERROR ("Failed to shut down appletviewer\n");
             }
         }
     }
@@ -1782,24 +1787,8 @@
 NPError
 initialize_data_directory()
 {
-  const char* tmpdir_env = getenv("TMPDIR");
-  if (tmpdir_env != NULL && g_file_test (tmpdir_env,
-                    (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
-  {
-    data_directory = tmpdir_env;
-  }
-  else if (g_file_test (P_tmpdir,


More information about the distro-pkg-dev mailing list