logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1587426 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
Date Tue, 15 Apr 2014 05:30:47 GMT
Author: mattsicker
Date: Tue Apr 15 05:30:47 2014
New Revision: 1587426

URL: http://svn.apache.org/r1587426
Log:
Use final where possible.

  - Also addresses a generics warning.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java?rev=1587426&r1=1587425&r2=1587426&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
Tue Apr 15 05:30:47 2014
@@ -87,31 +87,32 @@ public class AsyncLogger extends Logger 
     static enum ThreadNameStrategy { // LOG4J2-467
         CACHED {
             @Override
-            public String getThreadName(Info info) {
+            public String getThreadName(final Info info) {
                 return info.cachedThreadName;
             }
         },
         UNCACHED {
             @Override
-            public String getThreadName(Info info) {
+            public String getThreadName(final Info info) {
                 return Thread.currentThread().getName();
             }
         };
         abstract String getThreadName(Info info);
 
         static ThreadNameStrategy create() {
-            String name = System.getProperty("AsyncLogger.ThreadNameStrategy", CACHED.name());
+            final String name = System.getProperty("AsyncLogger.ThreadNameStrategy", CACHED.name());
             try {
                 return ThreadNameStrategy.valueOf(name);
-            } catch (Exception ex) {
+            } catch (final Exception ex) {
+                LOGGER.catching(ex);
                 return CACHED;
             }
         }
     }
     private static volatile Disruptor<RingBufferLogEvent> disruptor;
-    private static Clock clock = ClockFactory.getClock();
+    private static final Clock clock = ClockFactory.getClock();
 
-    private static ExecutorService executor = Executors
+    private static final ExecutorService executor = Executors
             .newSingleThreadExecutor(new DaemonThreadFactory("AsyncLogger-"));
 
     static {
@@ -122,10 +123,8 @@ public class AsyncLogger extends Logger 
         final WaitStrategy waitStrategy = createWaitStrategy();
         disruptor = new Disruptor<RingBufferLogEvent>(RingBufferLogEvent.FACTORY, ringBufferSize,
executor,
                 ProducerType.MULTI, waitStrategy);
-        final EventHandler<RingBufferLogEvent>[] handlers = new RingBufferLogEventHandler[]
{//
-        new RingBufferLogEventHandler() };
         disruptor.handleExceptionsWith(getExceptionHandler());
-        disruptor.handleEventsWith(handlers);
+        disruptor.handleEventsWith(new RingBufferLogEventHandler());
 
         LOGGER.debug("Starting AsyncLogger disruptor with ringbuffer size {}...", disruptor.getRingBuffer()
                 .getBufferSize());
@@ -218,7 +217,7 @@ public class AsyncLogger extends Logger 
         private final RingBufferLogEventTranslator translator;
         private final String cachedThreadName;
         private final boolean isAppenderThread;
-        public Info(RingBufferLogEventTranslator translator, String threadName, boolean appenderThread)
{
+        public Info(final RingBufferLogEventTranslator translator, final String threadName,
final boolean appenderThread) {
             this.translator = translator;
             this.cachedThreadName = threadName;
             this.isAppenderThread = appenderThread;
@@ -269,7 +268,7 @@ public class AsyncLogger extends Logger 
         disruptor.publishEvent(info.translator);
     }
 
-    private StackTraceElement location(final String fqcnOfLogger) {
+    private static StackTraceElement location(final String fqcnOfLogger) {
         return Log4jLogEvent.calcLocation(fqcnOfLogger);
     }
 
@@ -320,7 +319,7 @@ public class AsyncLogger extends Logger 
      * 
      * @param contextName name of the global {@code AsyncLoggerContext}
      */
-    public static RingBufferAdmin createRingBufferAdmin(String contextName) {
+    public static RingBufferAdmin createRingBufferAdmin(final String contextName) {
         return RingBufferAdmin.forAsyncLogger(disruptor.getRingBuffer(), contextName);
     }
 }



Mime
View raw message