Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r167 - trunk/src/ise/antelope/common

antelope
Discussion topic

Back to topic list

svn commit: r167 - trunk/src/ise/antelope/common

Author danson
Full name Dale Anson
Date 2009-07-01 16:10:04 PDT
Message Author: danson
Date: 2009-07-01 16:10:03-0700
New Revision: 167

Added:
   trunk/src/ise/antelo​pe/common/LoggerFact​ory.java
Modified:
   trunk/src/ise/antelo​pe/common/AntLogger.​java
   trunk/src/ise/antelo​pe/common/AntelopePa​nel.java

Log:
Start of refactoring of AntelopePanel.

Modified: trunk/src/ise/antelo​pe/common/AntLogger.​java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​AntLogger.java?view=​diff&pathrev=167​&r1=166&r2=1​67
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/common/AntLogger.​java (original)
+++ trunk/src/ise/antelo​pe/common/AntLogger.​java 2009-07-01 16:10:03-0700
@@ -53,15 +53,9 @@
 */
 package ise.antelope.common;
 
-import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.PrintStream;
-import java.io.StringReader;
 import java.io.File;
 
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.StringTokenizer;
 
 import java.util.logging.Logger;
 import java.util.logging.Level;
@@ -69,7 +63,6 @@
 import java.util.logging.Formatter;
 import java.util.logging.Handler;
 import java.util.logging.Co​nsoleHandler;
-import java.util.logging.Si​mpleFormatter;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant​.BuildEvent;
@@ -190,7 +183,7 @@
    /**
     * Namespace for logger
     */
- public static String NAMESPACE = "ise.antelope.Antelope";
+ public static String NAMESPACE = "ise.antelope.common​.AntLogger";
 
    /**
     * java.util.logging.Logger for namespace
@@ -264,7 +257,7 @@
             fileHandler.close();
          }
       }
- catch ( Exception ignored ) {}
+ catch ( Exception ignored ) {} // NOPMD
       open = false;
    }
 
@@ -623,7 +616,7 @@
                fileHandler.setFormatter( new PlainFormatter() );
                logger.addHandler( fileHandler );
             }
- catch ( Exception ignored ) {
+ catch ( Exception ignored ) { // NOPMD
                // silently ignore any error -- the alternative is to bail out
                // of the build.
             }
@@ -645,17 +638,7 @@
    private PrintStream createPrintStream() {
       PrintStream ps = new PrintStream(
                new java.io.OutputStream() {
- StringBuffer line = new StringBuffer();
                   public void write( int b ) {
- /*
- if ((byte)b == '\n') {
- log(line.toString());
- line = new StringBuffer();
- }
- else {
- line.append((byte)b);
- }
- */
                      byte[] bytes = {( byte ) b};
                      write( bytes, 0, 1 );
                   }

Modified: trunk/src/ise/antelo​pe/common/AntelopePa​nel.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​AntelopePanel.java?v​iew=diff&pathrev​=167&r1=166&​r2=167
====================​====================​====================​==================
--- trunk/src/ise/antelo​pe/common/AntelopePa​nel.java (original)
+++ trunk/src/ise/antelo​pe/common/AntelopePa​nel.java 2009-07-01 16:10:03-0700
@@ -135,7 +135,6 @@
 
     // basic logger settings
     private Logger _logger = null;
- private Level _log_level = Level.ALL;
 
     /** Description of the Field */
     private ArrayList _listeners = null;
@@ -411,7 +410,7 @@
         );
 
         // initialize the logger
- initLogger();
+ initLoggers();
 
         // initialize from the build file
         openBuildFile( build_file );
@@ -1864,41 +1863,12 @@
     }
 
     //==================​====================​====================​===
- // handle loggers, action listeners, and events
+ // handle loggers
     //==================​====================​====================​===
     /** Initializes the logger. */
- private void initLogger() {
- _logger = Logger.getLogger( "ise.antelope.Antelope" );
- _logger.setUseParentHandlers( false );
- _build_logger = new AntLogger();
-
- // do this after the AntLogger is created as the AntLogger
- // installs a ConsoleHandler by default, so remove all ConsoleHandlers
- // to be on the safe side.
- Handler[] handlers = _logger.getHandlers();
- try {
- for ( int i = 0; i < handlers.length; i++ ) {
- Handler handler = handlers[ i ];
- if ( handler instanceof ConsoleHandler ) {
- _logger.removeHandler( handler ); ///
- }
- }
- }
- catch ( Throwable e ) { // NOPMD
- Log.log( this, e );
- }
- _logger.setLevel( Level.ALL );
- }
-
-
- /**
- * Sets the log level for the default log handler. The default level is
- * Level.ALL, which is the most useful.
- *
- * @param level The new log level value
- */
- public void setLogLevel( Level level ) {
- _log_level = level;
+ private void initLoggers() {
+ _logger = LoggerFactory.getIns​tance().createLogger​();
+ _build_logger = LoggerFactory.getIns​tance().createAntLog​ger();
     }
 
 
@@ -1915,30 +1885,13 @@
             return ;
         }
         if ( _logger == null ) {
- initLogger();
+ _logger = LoggerFactory.getIns​tance().createLogger​();
         }
- h.setLevel( _log_level );
-
- // make sure it is really added, initLogger may remove it, so
- // explicitly add it again
- _logger.removeHandler( h );
+ h.setLevel( Level.ALL );
         _logger.addHandler( h );
     }
 
 
- /**
- * Removes the given handler from the logger for Antelope.
- *
- * @param h the Handler to remove
- */
- public void removeLogHandler( Handler h ) {
- if ( _logger == null ) {
- return ;
- }
- _logger.removeHandler( h );
- }
-
-
     /** Removes all log handlers from the logger for Antelope. */
     public void removeAllLogHandlers() {
         if ( _logger == null ) {

Added: trunk/src/ise/antelo​pe/common/LoggerFact​ory.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/trunk/src/​ise/antelope/common/​LoggerFactory.java?v​iew=markup&pathr​ev=167
====================​====================​====================​==================
--- (empty file)
+++ trunk/src/ise/antelo​pe/common/LoggerFact​ory.java 2009-07-01 16:10:03-0700
@@ -0,0 +1,32 @@
+package ise.antelope.common;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class LoggerFactory {
+
+ private static class SingletonHolder {
+ private static LoggerFactory INSTANCE = new LoggerFactory();
+ }
+
+ private LoggerFactory() {
+
+ }
+
+ public static LoggerFactory getInstance() {
+ return SingletonHolder.INSTANCE;
+ }
+
+ public Logger createLogger() {
+ Logger logger = Logger.getLogger( "ise.antelope.Antelope" );
+ logger.setUseParentHandlers( false );
+ logger.setLevel( Level.ALL );
+ return logger;
+
+
+ }
+
+ public AntLogger createAntLogger() {
+ return new AntLogger();
+ }
+}
\ No newline at end of file

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r167 - trunk/src/ise/antelope/common danson Dale Anson 2009-07-01 16:10:04 PDT
Messages per page: