krysalis-version/src/java/org/krysalis/version/util/logging LogHandleFactory.java,1.8,1.9

[email protected] Thu, 27 Mar 2003 15:17:51 -0800
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/util/logging
In directory sc8-pr-cvs1:/tmp/cvs-serv31680/src/java/org/krysalis/version/util/logging

Modified Files:
	LogHandleFactory.java 
Log Message:
Tryign to log into the Eclipse plugin log -- when inside Eclipse...

Index: LogHandleFactory.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/java/org/krysalis/version/util/logging/LogHandleFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** LogHandleFactory.java	25 Mar 2003 16:01:02 -0000	1.8
--- LogHandleFactory.java	27 Mar 2003 23:17:49 -0000	1.9
***************
*** 67,70 ****
--- 67,72 ----
      public static boolean g_enabled = false;
      public static boolean g_simple = false;
+     
+     private static Object l_context = null;
  
      private static LogHandleFactory l_factory = null;
***************
*** 73,76 ****
--- 75,80 ----
      private static final String COMMONS_FACTORY =
          "org.krysalis.version.util.logging.commons.CommonsLogHandleFactory";
+     private static final String ECLIPSE_FACTORY =
+         "org.krysalis.version.util.logging.eclipse.EclipseLogHandleFactory";
      //private static final String LOG4J_FACTORY =
      //    "org.krysalis.version.util.logging.commons.Log4jLogHandleFactory";
***************
*** 88,92 ****
                  (null
                      != System.getProperty(
!                         VersionImplementationConstants.VERSION_PACKAGE + ".logging"));
              simple =
                  (null
--- 92,97 ----
                  (null
                      != System.getProperty(
!                         VersionImplementationConstants.VERSION_PACKAGE
!                             + ".logging"));
              simple =
                  (null
***************
*** 99,102 ****
--- 104,108 ----
              System.err.println(
                  "SecurityException testing for logging. Logging disabled...");
+             e.printStackTrace(System.err);
              enabled = false;
          }
***************
*** 113,131 ****
  
      public static void enableLogging() {
!         
          // If 'simple' try stdout logging before commons..
          l_factory =
              g_simple
!                 ? (LogHandleFactory) RelativelySafe.loadClassWithFallback(
                      FALLBACK_FACTORY,
                      COMMONS_FACTORY)
!                 : (LogHandleFactory) RelativelySafe.loadClassWithFallback(
                      COMMONS_FACTORY,
                      FALLBACK_FACTORY);
  
          if (null == l_factory) {
- 
              System.err.println(
                  "Neither logging factory loaded successfully...");
              System.err.println("Commons Logging: " + COMMONS_FACTORY);
              System.err.println("Fallback Logging: " + FALLBACK_FACTORY);
--- 119,139 ----
  
      public static void enableLogging() {
! 
          // If 'simple' try stdout logging before commons..
          l_factory =
              g_simple
!                 ? (LogHandleFactory) RelativelySafe.loadClassWithFallbacks(
                      FALLBACK_FACTORY,
+                     ECLIPSE_FACTORY,
                      COMMONS_FACTORY)
!                 : (LogHandleFactory) RelativelySafe.loadClassWithFallbacks(
!                     ECLIPSE_FACTORY,
                      COMMONS_FACTORY,
                      FALLBACK_FACTORY);
  
          if (null == l_factory) {
              System.err.println(
                  "Neither logging factory loaded successfully...");
+             System.err.println("Eclipse Logging: " + ECLIPSE_FACTORY);
              System.err.println("Commons Logging: " + COMMONS_FACTORY);
              System.err.println("Fallback Logging: " + FALLBACK_FACTORY);
***************
*** 136,140 ****
--- 144,156 ----
      }
  
+ public static void registerDefaultContext(Object context){
+     l_context = context;
+ }
+ 
      public static LogHandle getLogHandle(String key) {
+         return getLogHandle(key, null);
+     }
+ 
+     public static LogHandle getLogHandle(String key, Object context) {
          LogHandle handle = null;
  
***************
*** 142,151 ****
  
              try {
! 
!                 handle = l_factory.getSpecializedLogHandle(key);
              }
              catch (Throwable t) {
                  System.err.println(
                      "Error configuring log handle. Logging disabled..." + t);
                  g_enabled = false;
              }
--- 158,167 ----
  
              try {
!                 handle = l_factory.getSpecializedLogHandle(key, context);
              }
              catch (Throwable t) {
                  System.err.println(
                      "Error configuring log handle. Logging disabled..." + t);
+                 t.printStackTrace(System.err);            
                  g_enabled = false;
              }
***************
*** 153,162 ****
  
          if (null == handle)
!             handle = l_disabledFactory.getSpecializedLogHandle(key);
  
          return handle;
      }
  
!     public abstract LogHandle getSpecializedLogHandle(String key);
  
      public static void main(String args[]) {
--- 169,180 ----
  
          if (null == handle)
!             handle = l_disabledFactory.getSpecializedLogHandle(key, context);
  
          return handle;
      }
  
!     public abstract LogHandle getSpecializedLogHandle(
!         String key,
!         Object context);
  
      public static void main(String args[]) {
***************
*** 165,173 ****
          System.out.println("isEnabled? " + g_enabled);
          System.out.println("isSimple? " + g_simple);
!         
          System.out.println("Log Class " + log.getClass().getName());
!         
          System.out.println("isDebugEnabled? " + log.isDebugEnabled());
!         
          log.debug("debug::Test...");
          log.error("error::Test...");
--- 183,191 ----
          System.out.println("isEnabled? " + g_enabled);
          System.out.println("isSimple? " + g_simple);
! 
          System.out.println("Log Class " + log.getClass().getName());
! 
          System.out.println("isDebugEnabled? " + log.isDebugEnabled());
! 
          log.debug("debug::Test...");
          log.error("error::Test...");




-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en