Author: unico
Date: Fri Aug 12 04:06:27 2005
New Revision: 232268

URL: http://svn.apache.org/viewcvs?rev=232268&view=rev
Log:
guarded logging

Modified:
    jakarta/slide/trunk/src/share/org/apache/slide/store/AbstractStore.java
    jakarta/slide/trunk/src/share/org/apache/slide/store/ExtendedStore.java
    
jakarta/slide/trunk/src/share/org/apache/slide/transaction/SlideTransactionManager.java
    
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
    
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
    
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java

Modified: 
jakarta/slide/trunk/src/share/org/apache/slide/store/AbstractStore.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/share/org/apache/slide/store/AbstractStore.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- jakarta/slide/trunk/src/share/org/apache/slide/store/AbstractStore.java 
(original)
+++ jakarta/slide/trunk/src/share/org/apache/slide/store/AbstractStore.java Fri 
Aug 12 04:06:27 2005
@@ -1786,7 +1786,9 @@
                 transaction.delistResource(service, TMFAIL);
                 String logMessage = Messages.format
                     (AbstractStore.class.getName() + ".delistFail", service);
-                getLogger().log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+                if (getLogger().isEnabled(Logger.DEBUG)) {
+                    getLogger().log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+                }
             }
         } catch (Exception e) {
             // Something went wrong.

Modified: 
jakarta/slide/trunk/src/share/org/apache/slide/store/ExtendedStore.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/share/org/apache/slide/store/ExtendedStore.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- jakarta/slide/trunk/src/share/org/apache/slide/store/ExtendedStore.java 
(original)
+++ jakarta/slide/trunk/src/share/org/apache/slide/store/ExtendedStore.java Fri 
Aug 12 04:06:27 2005
@@ -473,7 +473,9 @@
                 String key = uri.toString() + "_" + 
revisionDescriptor.getRevisionNumber();
                 Object result = contentCache.get(key);
                 if (result != null) {
-                    getLogger().log("Retrieving content at '" + key + "' from 
cache", LOG_CHANNEL, Logger.DEBUG);
+                    if (getLogger().isEnabled(Logger.DEBUG)) {
+                        getLogger().log("Retrieving content at '" + key + "' 
from cache", LOG_CHANNEL, Logger.DEBUG);
+                    }
                     // FIXME make a copy?! how?
                     return (NodeRevisionContent) result;
                 } else {
@@ -1410,7 +1412,9 @@
             try {
                 Xid txId = (Xid) activeTransactionBranch.get();
                 txCache.remove(txId, key);
-                getLogger().log("Removing content at '" + key + "' from 
cache", LOG_CHANNEL, Logger.DEBUG);
+                if (getLogger().isEnabled(Logger.DEBUG)) {
+                    getLogger().log("Removing content at '" + key + "' from 
cache", LOG_CHANNEL, Logger.DEBUG);
+                }
             } catch (Error e) {
                 fatalError(e);
             } catch (RuntimeException re) {
@@ -1424,7 +1428,9 @@
             try {
                 Xid txId = (Xid) activeTransactionBranch.get();
                 txCache.remove(txId, key, delimiter);
-                getLogger().log("Removing content at '" + key + "' with 
delimeter '" + delimiter + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+                if (getLogger().isEnabled(Logger.DEBUG)) {
+                    getLogger().log("Removing content at '" + key + "' with 
delimeter '" + delimiter + "' from cache", LOG_CHANNEL, Logger.DEBUG);
+                }
             } catch (Error e) {
                 fatalError(e);
             } catch (RuntimeException re) {
@@ -1493,10 +1499,12 @@
                     revisionContent.getContentBytes();
 
                     ((ByteSizeLimitedObjectCache) getTxCache()).put(null, key, 
revisionContent, byteSize);
-                    getLogger().log(
-                        "Globally caching content at '" + key + "' with " + 
byteSize + " bytes",
-                        LOG_CHANNEL,
-                        Logger.DEBUG);
+                    if (getLogger().isEnabled(Logger.DEBUG)) {
+                        getLogger().log(
+                            "Globally caching content at '" + key + "' with " 
+ byteSize + " bytes",
+                            LOG_CHANNEL,
+                            Logger.DEBUG);
+                    }
                 }
 
             } catch (Error e) {
@@ -1521,10 +1529,12 @@
                     revisionContent.getContentBytes();
 
                     ((ByteSizeLimitedObjectCache) getTxCache()).put(txId, key, 
revisionContent, byteSize, timeout);
-                    getLogger().log(
-                        "Caching content at '" + key + "' with " + byteSize + 
" bytes",
-                        LOG_CHANNEL,
-                        Logger.DEBUG);
+                    if (getLogger().isEnabled(Logger.DEBUG)) {
+                        getLogger().log(
+                            "Caching content at '" + key + "' with " + 
byteSize + " bytes",
+                            LOG_CHANNEL,
+                            Logger.DEBUG);
+                    }
                 } else {
                     // if we can not cache it, we need to invalidate global 
entry upon commit
                     getTxCache().remove(txId, key);

Modified: 
jakarta/slide/trunk/src/share/org/apache/slide/transaction/SlideTransactionManager.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/share/org/apache/slide/transaction/SlideTransactionManager.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- 
jakarta/slide/trunk/src/share/org/apache/slide/transaction/SlideTransactionManager.java
 (original)
+++ 
jakarta/slide/trunk/src/share/org/apache/slide/transaction/SlideTransactionManager.java
 Fri Aug 12 04:06:27 2005
@@ -217,7 +217,9 @@
         String logMessage = Messages.format
             (SlideTransactionManager.class.getName() + ".rollback",
              currentTransaction.toString());
-        logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+        if (getLogger().isEnabled(Logger.DEBUG)) {
+            logger.log(logMessage, LOG_CHANNEL, Logger.DEBUG);
+        }
 
         currentTransaction.rollback();
 

Modified: 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
 (original)
+++ 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/AbstractRDBMSStore.java
 Fri Aug 12 04:06:27 2005
@@ -207,8 +207,9 @@
     }
 
     public Xid[] recover(int flag) throws XAException {
-
-        getLogger().log("recover() for thread: " + Thread.currentThread(), 
LOG_CHANNEL, Logger.DEBUG);
+        if (getLogger().isEnabled(Logger.DEBUG)) {
+            getLogger().log("recover() for thread: " + Thread.currentThread(), 
LOG_CHANNEL, Logger.DEBUG);
+        }
         TransactionalResource id = getCurrentlyActiveTransactionalResource();
 
         if (id != null && id.getStatus() == STATUS_PREPARED) {
@@ -393,7 +394,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                getLogger().log("Outside of transaction:  retrieveObject 
"+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  retrieveObject 
"+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.retrieveObject(connection, uri);
             } catch (SQLException e) {
@@ -503,8 +506,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                
-                getLogger().log("Outside of transaction:  enumeratePermissions 
"+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  
enumeratePermissions "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.enumeratePermissions(connection, uri);
             } catch (SQLException e) {
@@ -591,7 +595,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                getLogger().log("Outside of transaction:  enumerateLocks 
"+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  enumerateLocks 
"+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.enumerateLocks(connection, uri);
             } catch (SQLException e) {
@@ -633,7 +639,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                getLogger().log("Outside of transaction:  
retrieveRevisionDescriptors "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  
retrieveRevisionDescriptors "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.retrieveRevisionDescriptors(connection, uri);
             } catch (SQLException e) {
@@ -712,7 +720,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                getLogger().log("Outside of transaction:  
retrieveRevisionDescriptor "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  
retrieveRevisionDescriptor "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.retrieveRevisionDescriptor(connection, uri, 
revisionNumber);
             } catch (SQLException e) {
@@ -792,7 +802,9 @@
         if (getCurrentlyActiveTransactionalResource() == null) {
             Connection connection = null;
             try {
-                getLogger().log("Outside of transaction:  
retrieveRevisionContent "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                if (getLogger().isEnabled(NO_CONNECTION_LOG_LEVEL)) {
+                    getLogger().log("Outside of transaction:  
retrieveRevisionContent "+uri, LOG_CHANNEL, NO_CONNECTION_LOG_LEVEL);
+                }
                 connection = getNewConnection();
                 return adapter.retrieveRevisionContent(connection, uri, 
revisionDescriptor, true);
             } catch (SQLException e) {
@@ -875,11 +887,14 @@
      * Get the Connection object associated with the current transaction.
      */
     protected Connection getCurrentConnection() throws ServiceAccessException {
-
-        getLogger().log("Getting current connection for thread " + 
Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+        if (getLogger().isEnabled(Logger.DEBUG)) {
+            getLogger().log("Getting current connection for thread " + 
Thread.currentThread(), LOG_CHANNEL, Logger.DEBUG);
+        }
         TransactionId id = (TransactionId) 
getCurrentlyActiveTransactionalResource();
         if (id == null) {
-            getLogger().log("No id for current thread - called outside 
transaction?", LOG_CHANNEL, Logger.DEBUG);
+            if (getLogger().isEnabled(Logger.DEBUG)) {
+                getLogger().log("No id for current thread - called outside 
transaction?", LOG_CHANNEL, Logger.DEBUG);
+            }
             return null;
         }
         return id.connection;

Modified: 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
 (original)
+++ 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
 Fri Aug 12 04:06:27 2005
@@ -308,7 +308,9 @@
             File tempFile = null;
             
             if (bcompress) {
-                getLogger().log("Compressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                if (getLogger().isEnabled(Logger.DEBUG)) {
+                    getLogger().log("Compressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                }
                 StoreContentZip ziputil = new StoreContentZip();
                 ziputil.Zip(is);
                 is = ziputil.getInputStream();
@@ -372,11 +374,12 @@
                     if (is != null) {
                         // XXX some JDBC drivers seem to close the stream upon 
closing of
                         // the statement; if so this will raise an IOException
-                        // silently ignore it...
                         try {
                             is.close();
                         } catch (IOException ioe) {
-                            logger.log("Could not close stream", ioe, 
LOG_CHANNEL, Logger.DEBUG);
+                            if (getLogger().isEnabled(Logger.DEBUG)) {
+                                logger.log("Could not close stream", ioe, 
LOG_CHANNEL, Logger.DEBUG);
+                            }
                         }
                     }
                 }

Modified: 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
URL: 
http://svn.apache.org/viewcvs/jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java?rev=232268&r1=232267&r2=232268&view=diff
==============================================================================
--- 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
 (original)
+++ 
jakarta/slide/trunk/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
 Fri Aug 12 04:06:27 2005
@@ -752,7 +752,9 @@
                 }
                 result = new NodeRevisionContent();
                 if (bcompress) {
-                    getLogger().log("DeCompressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                    if (getLogger().isEnabled(Logger.DEBUG)) {
+                        getLogger().log("DeCompressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                    }
                     StoreContentZip ziputil = new StoreContentZip();
                     ziputil.UnZip(is);
                     
revisionDescriptor.setContentLength(ziputil.getContentLength());
@@ -1048,10 +1050,12 @@
                     }
                 }
             }
-            getLogger().log(
-                revisionDescriptors.getOriginalUri() + 
revisionDescriptors.getInitialRevision(),
-                LOG_CHANNEL,
-                Logger.DEBUG);
+            if (getLogger().isEnabled(Logger.DEBUG)) {
+                getLogger().log(
+                    revisionDescriptors.getOriginalUri() + 
revisionDescriptors.getInitialRevision(),
+                    LOG_CHANNEL,
+                    Logger.DEBUG);
+            }
         } catch (SQLException e) {
             throw createException(e, uri.toString());
         }
@@ -1191,7 +1195,9 @@
             File tempFile = null;
             
             if (bcompress) {
-                getLogger().log("Compressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                if (getLogger().isEnabled(Logger.DEBUG)) {
+                    getLogger().log("Compressing the data", LOG_CHANNEL, 
Logger.DEBUG);
+                }
                 StoreContentZip ziputil = new StoreContentZip();
                 ziputil.Zip(is);
                 is = ziputil.getInputStream();
@@ -1255,12 +1261,13 @@
                 } finally {
                     if (is != null) {
                         // XXX some JDBC drivers seem to close the stream upon 
closing of 
-                        // the statement; if so this will raise an IOException 
-                        // silently ignore it...
+                        // the statement; if so this will raise an IOException
                         try {
                             is.close();
                         } catch (IOException ioe) {
-                            logger.log("Could not close stream", ioe, 
LOG_CHANNEL, Logger.DEBUG);
+                            if (getLogger().isEnabled(Logger.DEBUG)) {
+                                logger.log("Could not close stream", ioe, 
LOG_CHANNEL, Logger.DEBUG);
+                            }
                         }
                     }
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to