logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1225474 - in /logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j: EventLogger.java LogManager.java message/BasicThreadInformation.java message/MapMessage.java message/ThreadDumpMessage.java
Date Thu, 29 Dec 2011 08:40:41 GMT
Author: rgoers
Date: Thu Dec 29 08:40:41 2011
New Revision: 1225474

URL: http://svn.apache.org/viewvc?rev=1225474&view=rev
Log:
Fix checkstyle errors in API

Modified:
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
    logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java?rev=1225474&r1=1225473&r2=1225474&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/EventLogger.java
Thu Dec 29 08:40:41 2011
@@ -23,7 +23,12 @@ import org.apache.logging.log4j.spi.Abst
 /**
  *  Logs "Events" that are represented as StructuredDataMessages.
  */
-public class EventLogger {
+public final class EventLogger {
+
+    /**
+     * Define the Event Marker.
+     */
+    public static final Marker EVENT_MARKER = MarkerManager.getMarker("EVENT");
 
     private static final String FQCN = EventLogger.class.getName();
 
@@ -37,14 +42,16 @@ public class EventLogger {
         logger = new AbstractLoggerWrapper((AbstractLogger) l, "EventLogger");
     }
 
-    public static final Marker marker = MarkerManager.getMarker("EVENT");
+
+    private EventLogger() {
+    }
 
     /**
      * Log events with a level of ALL.
      * @param msg The event StructuredDataMessage.
      */
     public static void logEvent(StructuredDataMessage msg) {
-        logger.log(marker, FQCN, Level.OFF, msg, null);
+        logger.log(EVENT_MARKER, FQCN, Level.OFF, msg, null);
     }
 
     /**
@@ -53,6 +60,6 @@ public class EventLogger {
      * @param level The logging Level.
      */
     public static void logEvent(StructuredDataMessage msg, Level level) {
-        logger.log(marker, FQCN, level, msg, null);
+        logger.log(EVENT_MARKER, FQCN, level, msg, null);
     }
 }

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java?rev=1225474&r1=1225473&r2=1225474&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/LogManager.java
Thu Dec 29 08:40:41 2011
@@ -31,7 +31,9 @@ import java.util.Properties;
  * The anchor point for the logging system.
  */
 public class LogManager {
-
+    /**
+     * The name of the root Logger.
+     */
     public static final String ROOT_LOGGER_NAME = "";
 
     private static final String LOGGER_RESOURCE = "META-INF/log4j-provider.xml";

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java?rev=1225474&r1=1225473&r2=1225474&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/BasicThreadInformation.java
Thu Dec 29 08:40:41 2011
@@ -17,60 +17,69 @@
 package org.apache.logging.log4j.message;
 
 /**
- *
+ * Generates information about the current Thread. Used internally by ThreadDumpMessage.
  */
 class BasicThreadInformation implements ThreadInformation {
+    private static final int HASH_SHIFT = 32;
+    private static final int HASH_MULTIPLIER = 31;
+    private final long id;
+    private final String name;
+    private final String longName;
+    private final Thread.State state;
+    private final int priority;
+    private final boolean isAlive;
+    private final boolean isDaemon;
+    private final String threadGroupName;
+
+    /**
+     * The Constructor.
+     * @param thread The Thread to capture.
+     */
+    public BasicThreadInformation(Thread thread) {
+        this.id = thread.getId();
+        this.name = thread.getName();
+        this.longName = thread.toString();
+        this.state = thread.getState();
+        this.priority = thread.getPriority();
+        this.isAlive = thread.isAlive();
+        this.isDaemon = thread.isDaemon();
+        ThreadGroup group = thread.getThreadGroup();
+        threadGroupName = group == null ? null : group.getName();
+    }
 
-        private final long id;
-        private final String name;
-        private final String longName;
-        private final Thread.State state;
-        private final int priority;
-        private final boolean isAlive;
-        private final boolean isDaemon;
-        private final String threadGroupName;
-
-        public BasicThreadInformation(Thread thread) {
-            this.id = thread.getId();
-            this.name = thread.getName();
-            this.longName = thread.toString();
-            this.state = thread.getState();
-            this.priority = thread.getPriority();
-            this.isAlive = thread.isAlive();
-            this.isDaemon = thread.isDaemon();
-            ThreadGroup group = thread.getThreadGroup();
-            threadGroupName = group == null ? null : group.getName();
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-            if (o == null || getClass() != o.getClass()) {
-                return false;
-            }
-
-            BasicThreadInformation that = (BasicThreadInformation) o;
-
-            if (id != that.id) {
-                return false;
-            }
-            if (name != null ? !name.equals(that.name) : that.name != null) {
-                return false;
-            }
-
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
             return true;
         }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
 
-        @Override
-        public int hashCode() {
-            int result = (int) (id ^ (id >>> 32));
-            result = 31 * result + (name != null ? name.hashCode() : 0);
-            return result;
+        BasicThreadInformation that = (BasicThreadInformation) o;
+
+        if (id != that.id) {
+            return false;
+        }
+        if (name != null ? !name.equals(that.name) : that.name != null) {
+            return false;
         }
 
-     public void printThreadInfo(StringBuilder sb) {
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = (int) (id ^ (id >>> HASH_SHIFT));
+        result = HASH_MULTIPLIER * result + (name != null ? name.hashCode() : 0);
+        return result;
+    }
+
+    /**
+     * Print the thread information.
+     * @param sb The StringBuilder.
+     */
+    public void printThreadInfo(StringBuilder sb) {
         sb.append("\"").append(name).append("\" ");
         if (isDaemon) {
             sb.append("daemon ");
@@ -83,6 +92,11 @@ class BasicThreadInformation implements 
         sb.append("\tThread state: ").append(state.name()).append("\n");
     }
 
+    /**
+     * Format the StackTraceElements.
+     * @param sb The StringBuilder.
+     * @param trace The stack trace element array to format.
+     */
     public void printStack(StringBuilder sb, StackTraceElement[] trace) {
         for (StackTraceElement element : trace) {
             sb.append("\tat ").append(element).append("\n");

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java?rev=1225474&r1=1225473&r2=1225474&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/MapMessage.java
Thu Dec 29 08:40:41 2011
@@ -24,12 +24,13 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 
 /**
- * Represents a Message that conforms to RFC 5424 (http://tools.ietf.org/html/rfc5424).
+ * Represents a Message that consists of a Map.
  */
 public class MapMessage implements FormattedMessage, Serializable {
-
+    /**
+     * When set as the format specifier causes the Map to be formatted as XML.
+     */
     public static final String XML = "XML";
-    private static final int HASHVAL = 31;
     private static final long serialVersionUID = -5031471831131487120L;
 
     private final Map<String, String> data;

Modified: logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java?rev=1225474&r1=1225473&r2=1225474&view=diff
==============================================================================
--- logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
(original)
+++ logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers/log4j2-api/src/main/java/org/apache/logging/log4j/message/ThreadDumpMessage.java
Thu Dec 29 08:40:41 2011
@@ -33,14 +33,14 @@ public class ThreadDumpMessage implement
 
     private static final long serialVersionUID = -1103400781608841088L;
 
+    private static ThreadInfoFactory factory;
+
     private volatile Map<ThreadInformation, StackTraceElement[]> threads;
 
     private final String title;
 
     private String formattedMessage = null;
 
-    private static ThreadInfoFactory factory;
-
     static {
         Method[] methods = ThreadInfo.class.getMethods();
         boolean basic = true;
@@ -105,7 +105,7 @@ public class ThreadDumpMessage implement
     }
 
     /**
-     * Returns an array with a single element, a Map containing the ThreadInformation as
the key
+     * Returns an array with a single element, a Map containing the ThreadInformation as
the key.
      * and the StackTraceElement array as the value;
      * @return the "parameters" to this Message.
      */
@@ -149,10 +149,16 @@ public class ThreadDumpMessage implement
         }
     }
 
+    /**
+     * Factory to create Thread information.
+     */
     private interface ThreadInfoFactory {
         Map<ThreadInformation, StackTraceElement[]> createThreadInfo();
     }
 
+    /**
+     * Factory to create basic thread information.
+     */
     private static class BasicThreadInfoFactory implements ThreadInfoFactory {
         public Map<ThreadInformation, StackTraceElement[]> createThreadInfo() {
             Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces();
@@ -165,6 +171,9 @@ public class ThreadDumpMessage implement
         }
     }
 
+    /**
+     * Factory to create extended thread information.
+     */
     private static class ExtendedThreadInfoFactory implements ThreadInfoFactory {
         public Map<ThreadInformation, StackTraceElement[]> createThreadInfo() {
             ThreadMXBean bean = ManagementFactory.getThreadMXBean();



Mime
View raw message