diff options
author | Jiri Vanek <[email protected]> | 2014-01-20 14:59:17 +0100 |
---|---|---|
committer | Jiri Vanek <[email protected]> | 2014-01-20 14:59:17 +0100 |
commit | c6f420acd38b2036d17685efde866debc627c26e (patch) | |
tree | ae292a6d312001a1c212944884d3578de0d6889b | |
parent | c4bef6cad39892b850022c8f85c1edd97b0c7b40 (diff) |
Added support for system level linux logging
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/OutputController.java | 9 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java | 21 | ||||
-rw-r--r-- | plugin/icedteanp/IcedTeaPluginUtils.h | 13 | ||||
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginDebug.java | 2 | ||||
-rw-r--r-- | tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc | 42 |
6 files changed, 87 insertions, 12 deletions
@@ -1,3 +1,15 @@ +2014-01-20 Jiri Vanek <[email protected]> + + Added support for system level linux logging + * netx/net/sourceforge/jnlp/util/logging/OutputController.java: exclusive + handling for system critical *java* messages when system logging is on. + * netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java: implemented + call to logger + * plugin/icedteanp/IcedTeaPluginUtils.h: error messages logged to syslog + * plugin/icedteanp/java/sun/applet/PluginDebug.java: default messages + are now MESSAGE_DEBUG instead of ERROR_ALL + * tests/cpp-unit-tests/IcedTeaPluginUtilsTest.c: adapted to system logging + 2014-01-17 Andrew Azores <[email protected]> Added itweb-settings panel to explain custom policy files and allow diff --git a/netx/net/sourceforge/jnlp/util/logging/OutputController.java b/netx/net/sourceforge/jnlp/util/logging/OutputController.java index 3bec9f0..554a05d 100644 --- a/netx/net/sourceforge/jnlp/util/logging/OutputController.java +++ b/netx/net/sourceforge/jnlp/util/logging/OutputController.java @@ -174,8 +174,13 @@ public class OutputController { if (LogConfig.getLogConfig().isLogToFile()) { getFileLog().log(message); } - if (LogConfig.getLogConfig().isLogToSysLog()) { - getSystemLog().log(message); + //only crucial stuff is going to system log + //only java messages handled here, plugin is onhis own + if (LogConfig.getLogConfig().isLogToSysLog() && + (s.getHeader().level.equals(Level.ERROR_ALL) || s.getHeader().level.equals(Level.WARNING_ALL)) && + s.getHeader().isC == false) { + //no headers here + getSystemLog().log(s.getMessage()); } } diff --git a/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java b/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java index 157d91f..2571178 100644 --- a/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java +++ b/netx/net/sourceforge/jnlp/util/logging/UnixSystemLog.java @@ -44,14 +44,23 @@ public class UnixSystemLog implements SingleStreamLogger{ } - + @Override - public void log(String s) { - + public void log(String message) { + final String s = "IcedTea-Web java error - for more info see itweb-settings debug options or console. See http://icedtea.classpath.org/wiki/IcedTea-Web#Filing_bugs for help.\nIcedTea-Web java error manual log: \n" + message; + try { + String[] ss = s.split("\\n"); //exceptions have many lines + for (String m : ss) { + m = m.replaceAll("\t", " "); + ProcessBuilder pb = new ProcessBuilder("logger", "-p","user.err", "--", m); + Process p = pb.start(); + p.waitFor(); + OutputController.getLogger().log("System logger called with result of " + p.exitValue()); + } + } catch (Exception ex) { + OutputController.getLogger().log(ex); + } } - - - } diff --git a/plugin/icedteanp/IcedTeaPluginUtils.h b/plugin/icedteanp/IcedTeaPluginUtils.h index d65218a..e28ace3 100644 --- a/plugin/icedteanp/IcedTeaPluginUtils.h +++ b/plugin/icedteanp/IcedTeaPluginUtils.h @@ -47,6 +47,7 @@ exception statement from your version. */ #include <stdio.h> #include <stdlib.h> #include <time.h> +#include <syslog.h> #include <sys/time.h> #include <fcntl.h> @@ -154,6 +155,9 @@ void reset_pre_init_messages(); push_pre_init_messages(ldebug_channel_message); \ } \ } \ + if (plugin_debug_to_system){ \ + /*no debug messages to systemlog*/\ + } \ } \ } while (0) @@ -197,6 +201,15 @@ void reset_pre_init_messages(); push_pre_init_messages(ldebug_channel_message); \ } \ } \ + if (plugin_debug_to_system){ \ + /*java can not have prefix*/ \ + openlog("", LOG_NDELAY, LOG_USER);\ + syslog(LOG_ERR, "%s", "IcedTea-Web c-plugin - for more info see itweb-settings debug options or console. See http://icedtea.classpath.org/wiki/IcedTea-Web#Filing_bugs for help.");\ + syslog(LOG_ERR, "%s", "IcedTea-Web c-plugin error manual log:");\ + /*no headers to syslog*/ \ + syslog(LOG_ERR, "%s", ldebug_body); \ + closelog(); \ + } \ } while (0) diff --git a/plugin/icedteanp/java/sun/applet/PluginDebug.java b/plugin/icedteanp/java/sun/applet/PluginDebug.java index ef34ceb..f0e8370 100644 --- a/plugin/icedteanp/java/sun/applet/PluginDebug.java +++ b/plugin/icedteanp/java/sun/applet/PluginDebug.java @@ -53,7 +53,7 @@ public class PluginDebug { for (Object chunk : messageChunks) { b.append(chunk); } - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, b.toString()); + OutputController.getLogger().log(OutputController.Level.MESSAGE_DEBUG, b.toString()); } } } diff --git a/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc b/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc index 1ac2145..b9fa593 100644 --- a/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc +++ b/tests/cpp-unit-tests/IcedTeaPluginUtilsTest.cc @@ -138,7 +138,7 @@ TEST(file_exists) { } -void doDebugErrorRun() { +void doDebugErrorRun(int max) { FILE* old1 = stdout; FILE* old2 = stderr; char* buf1 = " "; @@ -149,7 +149,6 @@ void doDebugErrorRun() { clock_t begin1, end1; clock_t begin2, end2; int i; - int max = 1000000; std::string hello = std::string("hello"); std::string eello = std::string("eello"); @@ -172,7 +171,7 @@ void doDebugErrorRun() { } end2 = clock(); fclose(stdout); - fclose(stderr); + fclose(stderr); stdout = old1; stderr = old2; long time_spent1 = ((end1 - begin1)); @@ -181,27 +180,42 @@ void doDebugErrorRun() { fprintf (stdout, "PLUGIN_ERROR %d\n", time_spent2); } +void doDebugErrorRun() { + doDebugErrorRun(1000000); +} + +/* + *The family of PLUGIN_DEBUG_ERROR_PROFILING tests actually do not test. + *It is just messure that the mechanisms around do not break soething fataly. + */ + TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on_headers_off) { bool plugin_debug_backup = plugin_debug; bool plugin_debug_headers_backup = plugin_debug_headers; bool plugin_debug_console_backup = plugin_debug_to_console; + bool plugin_debug_system_backup = plugin_debug_to_system; plugin_debug_to_console = false; plugin_debug = true; + plugin_debug_to_system = false; //no need to torture system log in testing doDebugErrorRun(); plugin_debug = plugin_debug_backup; plugin_debug_headers = plugin_debug_headers_backup; plugin_debug_to_console = plugin_debug_console_backup; + plugin_debug_to_system = plugin_debug_system_backup; } TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_off_headers_off) { bool plugin_debug_backup = plugin_debug; bool plugin_debug_headers_backup = plugin_debug_headers; bool plugin_debug_console_backup = plugin_debug_to_console; + bool plugin_debug_system_backup = plugin_debug_to_system; plugin_debug_to_console = false; plugin_debug = false; + plugin_debug_to_system = false; //no need to torture system log in testing doDebugErrorRun(); plugin_debug = plugin_debug_backup; plugin_debug_headers = plugin_debug_headers_backup; plugin_debug_to_console = plugin_debug_console_backup; + plugin_debug_to_system = plugin_debug_system_backup; } @@ -209,25 +223,47 @@ TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on_headers_on) { bool plugin_debug_backup = plugin_debug; bool plugin_debug_headers_backup = plugin_debug_headers; bool plugin_debug_console_backup = plugin_debug_to_console; + bool plugin_debug_system_backup = plugin_debug_to_system; plugin_debug_to_console = false; plugin_debug = true; plugin_debug_headers = true; + plugin_debug_to_system = false; //no need to torture system log in testing doDebugErrorRun(); plugin_debug = plugin_debug_backup; plugin_debug_headers = plugin_debug_headers_backup; plugin_debug_to_console = plugin_debug_console_backup; + plugin_debug_to_system = plugin_debug_system_backup; } TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_off_headers_on) { bool plugin_debug_backup = plugin_debug; bool plugin_debug_headers_backup = plugin_debug_headers; bool plugin_debug_console_backup = plugin_debug_to_console; + bool plugin_debug_system_backup = plugin_debug_to_system; plugin_debug_to_console = false; plugin_debug = false; plugin_debug_headers = true; + plugin_debug_to_system = false; //no need to torture system log in testing doDebugErrorRun(); plugin_debug = plugin_debug_backup; plugin_debug_headers = plugin_debug_headers_backup; plugin_debug_to_console = plugin_debug_console_backup; + plugin_debug_to_system = plugin_debug_system_backup; +} + +TEST(PLUGIN_DEBUG_ERROR_PROFILING_debug_on_headers_on_syslog_on) { + bool plugin_debug_backup = plugin_debug; + bool plugin_debug_headers_backup = plugin_debug_headers; + bool plugin_debug_console_backup = plugin_debug_to_console; + bool plugin_debug_system_backup = plugin_debug_to_system; + plugin_debug_to_console = false; + plugin_debug = true; + plugin_debug_headers = true; + plugin_debug_to_system = true; + doDebugErrorRun(50); + plugin_debug = plugin_debug_backup; + plugin_debug_headers = plugin_debug_headers_backup; + plugin_debug_to_console = plugin_debug_console_backup; + plugin_debug_to_system = plugin_debug_system_backup; } |