[logback-dev] svn commit: r1976 - in logback/trunk: logback-access/src/main/java/ch/qos/logback/access/html logback-access/src/main/java/ch/qos/logback/access/jetty logback-access/src/main/java/ch/qos/logback/access/pattern logback-access/src/main/java/ch/qos/logback/access/tomcat logback-classic/src/main/java/ch/qos/logback/classic/html logback-classic/src/main/java/ch/qos/logback/classic/util logback-classic/src/test/java/ch/qos/logback/classic/html logback-classic/src/test/java/ch/qos/logback/classic/spi logback-core/src/main/java/ch/qos/logback/core logback-core/src/main/java/ch/qos/logback/core/html logback-core/src/main/java/ch/qos/logback/core/layout logback-core/src/main/java/ch/qos/logback/core/net logback-core/src/main/java/ch/qos/logback/core/util logback-core/src/test/java/ch/qos/logback/core/appender logback-core/src/test/java/ch/qos/logback/core/helpers logback-core/src/test/java/ch/qos/logback/core/layout logback-examples/src/main/java/chapter5

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Nov 17 17:42:16 CET 2008


Author: ceki
Date: Mon Nov 17 17:42:16 2008
New Revision: 1976

Modified:
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java
   logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java
   logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
   logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java

Log:
 - Moved LINE_SEP constant from Layout to CoreConstants.
 - Absorb thrown SecurityException/AccessControlException when accessing system properties
   This fixes LBCLASSIC-86

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/DefaultCssBuilder.java	Mon Nov 17 17:42:16 2008
@@ -9,7 +9,7 @@
  */
 package ch.qos.logback.access.html;
 
-import static ch.qos.logback.core.Layout.LINE_SEP;
+import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 import ch.qos.logback.core.html.CssBuilder;
 
 /**
@@ -31,49 +31,49 @@
     sbuf.append("margin-right: 2em; ");
     sbuf.append("border-left: 2px solid #AAA; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("TR.even { ");
     sbuf.append("background: #FFFFFF; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("TR.odd { ");
     sbuf.append("background: #EAEAEA; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("TD {");
     sbuf.append("padding-right: 1ex; ");
     sbuf.append("padding-left: 1ex; ");
     sbuf.append("border-right: 2px solid #AAA;");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("TD.Time, TD.Date { ");
     sbuf.append("text-align: right; ");
     sbuf.append("font-family: courier, monospace; ");
     sbuf.append("font-size: smaller; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf
         .append("TD.RemoteHost, TD.RequestProtocol, TD.RequestHeader, TD.RequestURL, TD.RemoteUser, TD.RequestURI, TD.ServerName {");
     sbuf.append("text-align: left; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf
         .append("TD.RequestAttribute, TD.RequestCookie, TD.ResponseHeader, TD.RequestParameter {");
     sbuf.append("text-align: left; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf
         .append("TD.RemoteIPAddress, TD.LocalIPAddress, TD.ContentLength, TD.StatusCode, TD.LocalPort {");
     sbuf.append("text-align: right; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("TR.header { ");
     sbuf.append("background: #596ED5; ");
     sbuf.append("color: #FFF; ");
     sbuf.append("font-weight: bold; ");
     sbuf.append("font-size: larger; ");
     sbuf.append("}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("</style>");
   }
 }
\ No newline at end of file

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/html/HTMLLayout.java	Mon Nov 17 17:42:16 2008
@@ -17,6 +17,7 @@
 import ch.qos.logback.core.html.HTMLLayoutBase;
 import ch.qos.logback.core.html.NOPThrowableRenderer;
 import ch.qos.logback.core.pattern.Converter;
+import static  ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 
 /**
  * 
@@ -64,14 +65,14 @@
       odd = false;
     }
 
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
     buf.append("<tr class=\"");
     if (odd) {
       buf.append(" odd\">");
     } else {
       buf.append(" even\">");
     }
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
 
     Converter<AccessEvent> c = head;
     while (c != null) {
@@ -79,7 +80,7 @@
       c = c.getNext();
     }
     buf.append("</tr>");
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
 
     return buf.toString();
   }
@@ -91,6 +92,6 @@
     buf.append("\">");
     buf.append(c.convert(event));
     buf.append("</td>");
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
   }
 }

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java	Mon Nov 17 17:42:16 2008
@@ -23,6 +23,7 @@
 import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.WarnStatus;
+import ch.qos.logback.core.util.OptionHelper;
 
 /**
  * This class is logback's implementation of jetty's RequestLog interface.
@@ -139,7 +140,7 @@
   public void start() {
 
     if (filename == null) {
-      String jettyHomeProperty = System.getProperty("jetty.home");
+      String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
 
       filename = jettyHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
       getStatusManager().add(

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullRequestConverter.java	Mon Nov 17 17:42:16 2008
@@ -3,7 +3,7 @@
 import java.util.Enumeration;
 
 import ch.qos.logback.access.spi.AccessEvent;
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 
 /**
  * This class is tied to the <code>fullRequest</code> conversion word.
@@ -20,7 +20,7 @@
   public String convert(AccessEvent ae) {
     StringBuffer buf = new StringBuffer();
     buf.append(ae.getRequestURL());
-    buf.append(Layout.LINE_SEP);
+    buf.append(CoreConstants.LINE_SEPARATOR);
     
     Enumeration headerNames = ae.getRequestHeaderNames();
     while(headerNames.hasMoreElements()) {
@@ -28,9 +28,9 @@
       buf.append(name);
       buf.append(": ");
       buf.append(ae.getRequestHeader(name));
-      buf.append(Layout.LINE_SEP);
+      buf.append(CoreConstants.LINE_SEPARATOR);
     }
-    buf.append(Layout.LINE_SEP);
+    buf.append(CoreConstants.LINE_SEPARATOR);
     buf.append(ae.getRequestContent());
     return buf.toString();
   }

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/pattern/FullResponseConverter.java	Mon Nov 17 17:42:16 2008
@@ -3,7 +3,7 @@
 import java.util.List;
 
 import ch.qos.logback.access.spi.AccessEvent;
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 
 public class FullResponseConverter extends AccessConverter {
 
@@ -16,18 +16,18 @@
     buf.append(statusCode);
     buf.append(" ");
     buf.append(getStatusCodeDescription(statusCode));
-    buf.append(Layout.LINE_SEP);
+    buf.append(CoreConstants.LINE_SEPARATOR);
     
     List<String> hnList = ae.getResponseHeaderNameList();
     for(String headerName: hnList) {
       buf.append(headerName);
       buf.append(": ");
       buf.append(ae.getResponseHeader(headerName));
-      buf.append(Layout.LINE_SEP);
+      buf.append(CoreConstants.LINE_SEPARATOR);
     }
-    buf.append(Layout.LINE_SEP);
+    buf.append(CoreConstants.LINE_SEPARATOR);
     buf.append(ae.getResponseContent());
-    buf.append(Layout.LINE_SEP);
+    buf.append(CoreConstants.LINE_SEPARATOR);
     return buf.toString();
   }
 

Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java	(original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java	Mon Nov 17 17:42:16 2008
@@ -30,24 +30,25 @@
 import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.StatusManager;
 import ch.qos.logback.core.status.WarnStatus;
+import ch.qos.logback.core.util.OptionHelper;
 import ch.qos.logback.core.util.StatusPrinter;
 
 /**
  * This class is an implementation of tomcat's Valve interface, by extending
  * ValveBase.
  * 
- * <p>For more information on using LogbackValve please refer to the online 
- * documentation on <a href="http://logback.qos.ch/access.html#tomcat">logback-acces and tomcat</a>.
+ * <p>For more information on using LogbackValve please refer to the online
+ * documentation on <a
+ * href="http://logback.qos.ch/access.html#tomcat">logback-acces and tomcat</a>.
  * 
- * <p>A special, module-specific implementation of PatternLayout was implemented to
- * allow http-specific patterns to be used. The
+ * <p>A special, module-specific implementation of PatternLayout was
+ * implemented to allow http-specific patterns to be used. The
  * {@link ch.qos.logback.access.PatternLayout} provides a way to format the
  * logging output that is just as easy and flexible as the usual PatternLayout.
  * For more information about the general use of a PatternLayout, please refer
  * to logback classic's {@link ch.qos.logback.classic.PatternLayout}. For
  * information about logback access' specific PatternLayout, please refer to
- * it's javadoc.
- * <p>
+ * it's javadoc. <p>
  * 
  * @author Ceki G&uuml;lc&uuml;
  * @author S&eacute;bastien Pennec
@@ -79,7 +80,8 @@
 
   public void start() {
     if (filename == null) {
-      String tomcatHomeProperty = System.getProperty("catalina.home");
+      String tomcatHomeProperty = OptionHelper
+          .getSystemProperty("catalina.home");
 
       filename = tomcatHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
       getStatusManager().add(
@@ -101,7 +103,7 @@
           new WarnStatus("[" + filename + "] does not exist", this));
     }
 
-    if(!quiet) {
+    if (!quiet) {
       StatusPrinter.print(getStatusManager());
     }
 
@@ -113,9 +115,9 @@
   }
 
   public void setFilename(String filename) {
-     this.filename = filename;
+    this.filename = filename;
   }
-  
+
   public boolean isQuiet() {
     return quiet;
   }
@@ -230,8 +232,6 @@
     this.name = name;
   }
 
-
-
   // Methods from catalina Lifecycle
 
   public void addLifecycleListener(LifecycleListener arg0) {

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultCssBuilder.java	Mon Nov 17 17:42:16 2008
@@ -1,7 +1,7 @@
 /**
- * Logback: the reliable, generic, fast and flexible logging framework.
+ * Logback: the generic, reliable, fast and flexible logging framework.
  * 
- * Copyright (C) 1999-2006, QOS.ch
+ * Copyright (C) 2000-2008, QOS.ch
  * 
  * This library is free software, you can redistribute it and/or modify it under
  * the terms of the GNU Lesser General Public License as published by the Free
@@ -9,7 +9,9 @@
  */
 package ch.qos.logback.classic.html;
 
-import static ch.qos.logback.core.Layout.LINE_SEP;
+
+import ch.qos.logback.core.CoreConstants;
+import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 import ch.qos.logback.core.html.CssBuilder;
 
 /**
@@ -26,47 +28,47 @@
 
   public void addCss(StringBuilder sbuf) {
     sbuf.append("<style  type=\"text/css\">");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf
         .append("table { margin-left: 2em; margin-right: 2em; border-left: 2px solid #AAA; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("TR.even { background: #FFFFFF; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("TR.odd { background: #EAEAEA; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf
         .append("TR.warn TD.Level, TR.error TD.Level, TR.fatal TD.Level {font-weight: bold; color: #FF4040 }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(CoreConstants.LINE_SEPARATOR);
 
     sbuf
         .append("TD { padding-right: 1ex; padding-left: 1ex; border-right: 2px solid #AAA; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf
         .append("TD.Time, TD.Date { text-align: right; font-family: courier, monospace; font-size: smaller; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("TD.Thread { text-align: left; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("TD.Level { text-align: right; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("TD.Logger { text-align: left; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf
         .append("TR.header { background: #596ED5; color: #FFF; font-weight: bold; font-size: larger; }");
-    sbuf.append(LINE_SEP);
+    sbuf.append(CoreConstants.LINE_SEPARATOR);
 
     sbuf
         .append("TD.Exception { background: #A2AEE8; font-family: courier, monospace;}");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     sbuf.append("</style>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
   }
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/DefaultThrowableRenderer.java	Mon Nov 17 17:42:16 2008
@@ -1,6 +1,6 @@
 package ch.qos.logback.classic.html;
 
-import static ch.qos.logback.core.Layout.LINE_SEP;
+import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 import ch.qos.logback.classic.helpers.Transform;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.classic.spi.ThrowableDataPoint;
@@ -29,11 +29,11 @@
       }
       sbuf.append("<tr><td class=\"Exception\" colspan=\"6\">");
       sbuf.append(Transform.escapeTags(tdpArray[0].toString()));
-      sbuf.append(LINE_SEP);
+      sbuf.append(LINE_SEPARATOR);
       for (int i = 1; i < len; i++) {
         sbuf.append(TRACE_PREFIX);
         sbuf.append(Transform.escapeTags(tdpArray[i].toString()));
-        sbuf.append(LINE_SEP);
+        sbuf.append(LINE_SEPARATOR);
       }
       sbuf.append("</td></tr>");
     }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java	Mon Nov 17 17:42:16 2008
@@ -17,6 +17,7 @@
 import ch.qos.logback.classic.html.DefaultCssBuilder;
 import ch.qos.logback.core.html.HTMLLayoutBase;
 import ch.qos.logback.core.pattern.Converter;
+import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 
 /**
  * 
@@ -65,7 +66,7 @@
 
     String level = event.getLevel().toString().toLowerCase();
 
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
     buf.append("<tr class=\"");
     buf.append(level);
     if (odd) {
@@ -73,7 +74,7 @@
     } else {
       buf.append(" even\">");
     }
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
 
     Converter<LoggingEvent> c = head;
     while (c != null) {
@@ -81,7 +82,7 @@
       c = c.getNext();
     }
     buf.append("</tr>");
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
 
     if (event.getThrowableProxy() != null) {
       throwableRenderer.render(buf, event);
@@ -96,6 +97,6 @@
     buf.append("\">");
     buf.append(c.convert(event));
     buf.append("</td>");
-    buf.append(LINE_SEP);
+    buf.append(LINE_SEPARATOR);
   }
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/ContextInitializer.java	Mon Nov 17 17:42:16 2008
@@ -11,6 +11,7 @@
 import ch.qos.logback.core.status.InfoStatus;
 import ch.qos.logback.core.status.StatusManager;
 import ch.qos.logback.core.util.Loader;
+import ch.qos.logback.core.util.OptionHelper;
 
 // contributors
 // Ted Graham, Matt Fowles, see also http://jira.qos.ch/browse/LBCORE-32
@@ -43,7 +44,7 @@
   }
 
   private URL findConfigFileURLFromSystemProperties(boolean updateStatus) {
-    String logbackConfigFile = System.getProperty(CONFIG_FILE_PROPERTY, null);
+    String logbackConfigFile = OptionHelper.getSystemProperty(CONFIG_FILE_PROPERTY);
     if (logbackConfigFile != null) {
       URL result = null;
       try {

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/StatusListenerConfigHelper.java	Mon Nov 17 17:42:16 2008
@@ -8,8 +8,8 @@
 public class StatusListenerConfigHelper {
 
   static void installIfAsked(LoggerContext loggerContext) {
-    String slClass = System.getProperty(
-        ContextInitializer.STATUS_LISTENER_CLASS, null);
+    String slClass = OptionHelper.getSystemProperty(
+        ContextInitializer.STATUS_LISTENER_CLASS);
     if (!OptionHelper.isEmpty(slClass)) {
       addStatusListener(loggerContext, slClass);
     }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java	Mon Nov 17 17:42:16 2008
@@ -94,7 +94,7 @@
         .getThrowableRenderer();
     renderer.render(buf, strArray);
     // System.out.println(buf.toString());
-    String[] result = buf.toString().split(HTMLLayout.LINE_SEP);
+    String[] result = buf.toString().split(CoreConstants.LINE_SEPARATOR);
     assertEquals("<tr><td class=\"Exception\" colspan=\"6\">test1", result[0]);
     assertEquals(DefaultThrowableRenderer.TRACE_PREFIX + "test2", result[1]);
   }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/ThrowableToDataPointTest.java	Mon Nov 17 17:42:16 2008
@@ -1,6 +1,6 @@
 package ch.qos.logback.classic.spi;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -9,9 +9,7 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import ch.qos.logback.classic.spi.ThrowableDataPoint;
-import ch.qos.logback.classic.spi.ThrowableToDataPointArray;
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 
 public class ThrowableToDataPointTest {
 
@@ -33,7 +31,7 @@
     StringBuilder sb = new StringBuilder();
     for (ThrowableDataPoint tdp : tdpArray) {
       sb.append(tdp.toString());
-      sb.append(Layout.LINE_SEP);
+      sb.append(CoreConstants.LINE_SEPARATOR);
     }
     String expected = sw.toString();
     String result = sb.toString().replace("common frames omitted", "more");

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Layout.java	Mon Nov 17 17:42:16 2008
@@ -13,9 +13,6 @@
 import ch.qos.logback.core.spi.LifeCycle;
 
 public interface Layout<E> extends ContextAware, LifeCycle {
-  // Note that the line.separator property can be looked up even by applets.
-  public static final String LINE_SEP = System.getProperty("line.separator");
-  public static final int LINE_SEP_LEN = LINE_SEP.length();
   
   /**
    * Transform an event (of type Object) and return it as a String after 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/WriterAppender.java	Mon Nov 17 17:42:16 2008
@@ -204,7 +204,7 @@
         appendIfNotNull(sb, layout.getFileHeader());
         appendIfNotNull(sb, layout.getPresentationHeader());
         if (sb.length() > 0) {
-          sb.append(Layout.LINE_SEP);
+          sb.append(CoreConstants.LINE_SEPARATOR);
           // If at least one of file header or presentation header were not
           // null, then append a line separator.
           // This should be useful in most cases and should not hurt.

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/html/HTMLLayoutBase.java	Mon Nov 17 17:42:16 2008
@@ -3,6 +3,7 @@
 import java.util.Map;
 
 import ch.qos.logback.core.CoreConstants;
+import static ch.qos.logback.core.CoreConstants.LINE_SEPARATOR;
 import ch.qos.logback.core.LayoutBase;
 import ch.qos.logback.core.pattern.Converter;
 import ch.qos.logback.core.pattern.ConverterUtil;
@@ -120,15 +121,15 @@
     StringBuilder sbuf = new StringBuilder();
     sbuf.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
     sbuf.append(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("<html>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("  <head>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("    <title>");
     sbuf.append(title);
     sbuf.append("</title>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     
     cssBuilder.addCss(sbuf);
 //    if (cssBuilder == null) {
@@ -136,11 +137,11 @@
 //    } else {
 //      cssBuilder.addExternalCSS(sbuf);
 //    }
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("  </head>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("<body>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     return sbuf.toString();
   }
@@ -148,14 +149,14 @@
   public String getPresentationHeader() {
     StringBuilder sbuf = new StringBuilder();
     sbuf.append("<hr/>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("<p>Log session start time ");
     sbuf.append(new java.util.Date());
     sbuf.append("</p><p></p>");
-    sbuf.append(LINE_SEP);
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("<table cellspacing=\"0\">");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
 
     buildHeaderRowForTable(sbuf);
     
@@ -167,7 +168,7 @@
     Converter c = head;
     String name;
     sbuf.append("<tr class=\"header\">");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     while (c != null) {
       name = computeConverterName(c);
       if (name == null) {
@@ -179,11 +180,11 @@
       sbuf.append("\">");
       sbuf.append(computeConverterName(c));
       sbuf.append("</td>");
-      sbuf.append(LINE_SEP);
+      sbuf.append(LINE_SEPARATOR);
       c = c.getNext();
     }
     sbuf.append("</tr>");
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
   }
   
   public String getPresentationFooter() {
@@ -198,7 +199,7 @@
   @Override
   public String getFileFooter() {
     StringBuilder sbuf = new StringBuilder();
-    sbuf.append(LINE_SEP);
+    sbuf.append(LINE_SEPARATOR);
     sbuf.append("</body></html>");
     return sbuf.toString();
   }
@@ -207,10 +208,10 @@
     if (this.counter >= CoreConstants.TABLE_ROW_LIMIT) {
       counter = 0;
       sbuf.append("</table>");
-      sbuf.append(LINE_SEP);
+      sbuf.append(LINE_SEPARATOR);
       sbuf.append("<p></p>");
       sbuf.append("<table cellspacing=\"0\">");
-      sbuf.append(LINE_SEP);
+      sbuf.append(LINE_SEPARATOR);
       buildHeaderRowForTable(sbuf);
     }
   }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/layout/EchoLayout.java	Mon Nov 17 17:42:16 2008
@@ -9,7 +9,7 @@
  */
 package ch.qos.logback.core.layout;
 
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.LayoutBase;
 
 /**
@@ -20,7 +20,7 @@
 public class EchoLayout<E> extends LayoutBase<E> {
 
   public String doLayout(E event) {
-    return event+Layout.LINE_SEP;
+    return event+CoreConstants.LINE_SEPARATOR;
   }
 
 }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java	Mon Nov 17 17:42:16 2008
@@ -30,6 +30,7 @@
 import ch.qos.logback.core.Layout;
 import ch.qos.logback.core.boolex.EvaluationException;
 import ch.qos.logback.core.boolex.EventEvaluator;
+import ch.qos.logback.core.util.OptionHelper;
 
 /**
  * An abstract class that provides support for sending events to an email
@@ -83,7 +84,7 @@
    * Start the appender
    */
   public void start() {
-    Properties props = new Properties(System.getProperties());
+    Properties props = new Properties(OptionHelper.getSystemProperties());
     if (smtpHost != null) {
       props.put("mail.smtp.host", smtpHost);
     }

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java	Mon Nov 17 17:42:16 2008
@@ -9,6 +9,9 @@
  */
 package ch.qos.logback.core.util;
 
+
+import java.util.Properties;
+
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
 
@@ -198,7 +201,7 @@
 
   /**
    * Very similar to <code>System.getProperty</code> except that the
-   * {@link SecurityException} is hidden.
+   * {@link SecurityException} is absorbed.
    * 
    * @param key
    *          The key to search for.
@@ -210,12 +213,41 @@
   public static String getSystemProperty(String key, String def) {
     try {
       return System.getProperty(key, def);
-    } catch (Throwable e) { // MS-Java throws
-      // com.ms.security.SecurityExceptionEx
+    } catch (SecurityException e) {
       return def;
     }
   }
 
+  /**
+   * Very similar to <code>System.getProperty</code> except that the
+   * {@link SecurityException} is absorbed.
+   * 
+   * @param key
+   *          The key to search for.
+
+   * @return the string value of the system property.
+   */
+  public static String getSystemProperty(String key) {
+    try {
+      return System.getProperty(key);
+    } catch (SecurityException e) {
+      return null;
+    }
+  }
+  /**
+   * Very similar to {@link System#getProperties()} except that the
+   * {@link SecurityException} is absorbed.
+   * 
+   * @return the system properties
+   */
+  public static Properties getSystemProperties() {
+    try {
+      return System.getProperties();
+    } catch (SecurityException e) {
+      return new Properties();
+    }
+  }
+  
   static public String[] extractDefaultReplacement(String key) {
     String[] result = new String[2];
     result[0] = key;

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/StatusPrinter.java	Mon Nov 17 17:42:16 2008
@@ -18,7 +18,6 @@
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.Layout;
 import ch.qos.logback.core.helpers.ThrowableToStringArray;
 import ch.qos.logback.core.status.ErrorStatus;
 import ch.qos.logback.core.status.Status;
@@ -132,7 +131,7 @@
       String dateStr = simpleDateFormat.format(date);
       sb.append(dateStr).append(" ");
     }
-    sb.append(prefix).append(s).append(Layout.LINE_SEP);
+    sb.append(prefix).append(s).append(CoreConstants.LINE_SEPARATOR);
 
     if (s.getThrowable() != null) {
       appendThrowable(sb, s.getThrowable());

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/appender/ConsoleAppenderTest.java	Mon Nov 17 17:42:16 2008
@@ -18,10 +18,9 @@
 import org.junit.Before;
 import org.junit.Test;
 
-
 import ch.qos.logback.core.AppenderBase;
 import ch.qos.logback.core.ConsoleAppender;
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.layout.DummyLayout;
 import ch.qos.logback.core.layout.NopLayout;
 import ch.qos.logback.core.util.TeeOutputStream;
@@ -83,7 +82,7 @@
     ca.start();
     ca.doAppend(new Object());
     ca.stop();
-    assertEquals("open"+Layout.LINE_SEP+DummyLayout.DUMMY, tee.toString());
+    assertEquals("open"+CoreConstants.LINE_SEPARATOR+DummyLayout.DUMMY, tee.toString());
   }
   
   @Test

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/helpers/ThrowableToStringArrayTest.java	Mon Nov 17 17:42:16 2008
@@ -1,6 +1,6 @@
 package ch.qos.logback.core.helpers;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -9,7 +9,7 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import ch.qos.logback.core.Layout;
+import ch.qos.logback.core.CoreConstants;
 
 public class ThrowableToStringArrayTest {
 
@@ -31,7 +31,7 @@
     StringBuilder sb = new StringBuilder();
     for (String tdp : sa) {
       sb.append(tdp.toString());
-      sb.append(Layout.LINE_SEP);
+      sb.append(CoreConstants.LINE_SEPARATOR);
     }
     String expected = sw.toString();
     String result = sb.toString().replace("common frames omitted", "more");

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/layout/DummyLayout.java	Mon Nov 17 17:42:16 2008
@@ -9,11 +9,12 @@
  */
 package ch.qos.logback.core.layout;
 
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.LayoutBase;
 
 public class DummyLayout<E> extends LayoutBase<E> {
 
-  public static final String DUMMY = "dummy"+LINE_SEP;
+  public static final String DUMMY = "dummy"+CoreConstants.LINE_SEPARATOR;
   String val = DUMMY;
   
   public DummyLayout() {

Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java	(original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout.java	Mon Nov 17 17:42:16 2008
@@ -1,6 +1,7 @@
 package chapter5;
 
 import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.LayoutBase;
 
 public class MySampleLayout extends LayoutBase<LoggingEvent>  {
@@ -16,7 +17,7 @@
     sbuf.append(event.getLoggerRemoteView().getName());
     sbuf.append(" - ");
     sbuf.append(event.getFormattedMessage());
-    sbuf.append(LINE_SEP);
+    sbuf.append(CoreConstants.LINE_SEPARATOR);
     return sbuf.toString();
   }
 }
\ No newline at end of file

Modified: logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java	(original)
+++ logback/trunk/logback-examples/src/main/java/chapter5/MySampleLayout2.java	Mon Nov 17 17:42:16 2008
@@ -1,6 +1,7 @@
 package chapter5;
 
 import ch.qos.logback.classic.spi.LoggingEvent;
+import ch.qos.logback.core.CoreConstants;
 import ch.qos.logback.core.LayoutBase;
 
 public class MySampleLayout2 extends LayoutBase<LoggingEvent> {
@@ -34,7 +35,7 @@
     sbuf.append(event.getLoggerRemoteView().getName());
     sbuf.append(" - ");
     sbuf.append(event.getFormattedMessage());
-    sbuf.append(LINE_SEP);
+    sbuf.append(CoreConstants.LINE_SEPARATOR);
     return sbuf.toString();
   }
 }
\ No newline at end of file


More information about the logback-dev mailing list