You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/09/02 14:34:49 UTC

[2/4] logging-log4j2 git commit: Use constants, not magic strings.

Use constants, not magic strings.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f44785b9
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f44785b9
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f44785b9

Branch: refs/heads/LOG4J2-1558
Commit: f44785b9332afeab10cef3ac3a9618569c85918a
Parents: 0752fed
Author: ggregory <gg...@apache.org>
Authored: Fri Sep 2 07:25:04 2016 -0700
Committer: ggregory <gg...@apache.org>
Committed: Fri Sep 2 07:25:04 2016 -0700

----------------------------------------------------------------------
 .../builder/impl/DefaultConfigurationBuilder.java    | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f44785b9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
index 5e702ab..acec63c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/DefaultConfigurationBuilder.java
@@ -53,6 +53,9 @@ import org.apache.logging.log4j.core.util.Throwables;
  */
 public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implements ConfigurationBuilder<T> {
 
+    private static final String INDENT = "\t";
+    private static final String EOL = "\n";
+    
     private final Component root = new Component();
     private Component loggers;
     private Component appenders;
@@ -225,7 +228,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
 
     private void writeXmlConfiguration(XMLStreamWriter xmlWriter) throws XMLStreamException {
         xmlWriter.writeStartDocument();
-        xmlWriter.writeCharacters("\n");
+        xmlWriter.writeCharacters(EOL);
 
         xmlWriter.writeStartElement("Configuration");
         if (name != null) {
@@ -253,7 +256,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
             xmlWriter.writeAttribute("monitorInterval", String.valueOf(monitorInterval));
         }
 
-        xmlWriter.writeCharacters("\n");
+        xmlWriter.writeCharacters(EOL);
 
         writeXmlSection(xmlWriter, properties);
         writeXmlSection(xmlWriter, scripts);
@@ -267,7 +270,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
         writeXmlSection(xmlWriter, loggers);
 
         xmlWriter.writeEndElement(); // "Configuration"
-        xmlWriter.writeCharacters("\n");
+        xmlWriter.writeCharacters(EOL);
 
         xmlWriter.writeEndDocument();
     }
@@ -284,7 +287,7 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
             xmlWriter.writeStartElement(component.getPluginType());
             writeXmlAttributes(xmlWriter, component);
             if (!component.getComponents().isEmpty()) {
-                xmlWriter.writeCharacters("\n");
+                xmlWriter.writeCharacters(EOL);
             }
             for (Component subComponent : component.getComponents()) {
                 writeXmlComponent(xmlWriter, subComponent, nesting + 1);
@@ -301,12 +304,12 @@ public class DefaultConfigurationBuilder<T extends BuiltConfiguration> implement
             xmlWriter.writeEmptyElement(component.getPluginType());
             writeXmlAttributes(xmlWriter, component);
         }
-        xmlWriter.writeCharacters("\n");
+        xmlWriter.writeCharacters(EOL);
     }
 
     private void writeXmlIndent(XMLStreamWriter xmlWriter, int nesting) throws XMLStreamException {
         for (int i = 0; i < nesting; i++) {
-            xmlWriter.writeCharacters("\t");
+            xmlWriter.writeCharacters(INDENT);
         }
     }