[sip-comm-dev] Re: svn commit: r7199 - trunk/src/net/java/sip/communicator/impl: gui gui/main gui/main/account gui/main/chat gui/main/chat/conference gui/main/chat/fi...


#1

Hello Werner,
as it is a good idea to add guard around log usage, I think some
specific case shoud not be guarded.

When the log message is a static String, it doesn't involve
unnecessary resource consumption like String concatenation would do.
So adding that test here is a resource waste because the test will be
done twice, one in your guard, and the second time in the logger
itself
For example in
GuiActivator

if (logger.isInfoEnabled())
                logger.info("UI Service...[ STARTED ]");

should be replaced by
logger.info("UI Service...[ STARTED ]");

Matthieu

···

2010/6/3 <wernerd@dev.java.net>:

Author: wernerd
Date: 2010-06-03 09:04:07+0000
New Revision: 7199

Modified:
trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java
trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java (contents, props changed)
trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java
trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java
trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java (contents, props changed)
trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java
trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java
trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java (contents, props changed)
trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java
trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java
trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java
trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java
trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java

Log:
Fix logger usage - forth bunch.

Modified: trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java&p2=trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java 2010-06-03 09:04:07+0000
@@ -110,12 +110,14 @@
// Create the ui service
uiService = new UIServiceImpl();

- logger.info("UI Service...[ STARTED ]");
+ if (logger.isInfoEnabled())
+ logger.info("UI Service...[ STARTED ]");

        bundleContext\.registerService\(UIService\.class\.getName\(\),
                                      uiService,
                                      null\);

- logger.info("UI Service ...[REGISTERED]");
+ if (logger.isInfoEnabled())
+ logger.info("UI Service ...[REGISTERED]");

        // UIServiceImpl also implements ShutdownService\.
        bundleContext\.registerService\(ShutdownService\.class\.getName\(\),

@@ -154,7 +156,8 @@
*/
public void stop(BundleContext bContext) throws Exception
{
- logger.info("UI Service ...[STOPPED]");
+ if (logger.isInfoEnabled())
+ logger.info("UI Service ...[STOPPED]");
isStarted = false;

    GuiActivator\.getConfigurationService\(\)

Modified: trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&p2=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java 2010-06-03 09:04:07+0000
@@ -188,7 +188,8 @@
PluginComponentEvent evt =
new PluginComponentEvent(pluginComponent, eventID);

- logger.debug("Will dispatch the following plugin component event: "
+ if (logger.isDebugEnabled())
+ logger.debug("Will dispatch the following plugin component event: "
+ evt);

    synchronized \(pluginComponentListeners\)

@@ -940,14 +941,16 @@
switch (event.getType())
{
case ServiceEvent.REGISTERED:
- logger.info("Handling registration of a new Plugin Component.");
+ if (logger.isInfoEnabled())
+ logger.info("Handling registration of a new Plugin Component.");

        Object component = pluginComponent\.getComponent\(\);
        if \(\!\(component instanceof Component\)\)
        \{
            logger\.error\(&quot;Plugin Component type is not supported\.&quot;
                \+ &quot;Should provide a plugin in AWT, SWT or Swing\.&quot;\);

- logger.debug("Logging exception to show the calling plugin",
+ if (logger.isDebugEnabled())
+ logger.debug("Logging exception to show the calling plugin",
new Exception(""));
return;
}

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java 2010-06-03 09:04:07+0000
@@ -507,7 +507,8 @@
*/
public void addProtocolProvider(ProtocolProviderService protocolProvider)
{
- logger.trace("Add the following protocol provider to the gui: "
+ if (logger.isTraceEnabled())
+ logger.trace("Add the following protocol provider to the gui: "
+ protocolProvider.getAccountID().getAccountAddress());

    this\.protocolProviders\.put\(protocolProvider,

@@ -547,7 +548,8 @@
{
if (!accountStatusPanel.containsAccount(protocolProvider))
{
- logger.trace("Add the following account to the status bar: "
+ if (logger.isTraceEnabled())
+ logger.trace("Add the following account to the status bar: "
+ protocolProvider.getAccountID().getAccountAddress());

        accountStatusPanel\.addAccount\(protocolProvider\);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegSummaryPage.java 2010-06-03 09:04:07+0000
@@ -170,7 +170,8 @@
}
catch (OperationFailedException e)
{
- logger.debug("The sign in operation has failed.");
+ if (logger.isDebugEnabled())
+ logger.debug("The sign in operation has failed.");

        if \(e\.getErrorCode\(\)
                == OperationFailedException\.ILLEGAL\_ARGUMENT\)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/account/AccountRegWizardContainerImpl.java 2010-06-03 09:04:07+0000
@@ -75,7 +75,8 @@
// in case we found any, add them in this container.
if (accountWizardRefs != null)
{
- logger.debug("Found "
+ if (logger.isDebugEnabled())
+ logger.debug("Found "
+ accountWizardRefs.length
+ " already installed providers.");
for (ServiceReference serRef : accountWizardRefs)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/account/NewAccountDialog.java 2010-06-03 09:04:07+0000
@@ -152,7 +152,8 @@
// in case we found any, add them in this container.
if (accountWizardRefs != null)
{
- logger.debug("Found "
+ if (logger.isDebugEnabled())
+ logger.debug("Found "
+ accountWizardRefs.length
+ " already installed providers.");

@@ -377,7 +378,8 @@
// If the sign in operation has failed we don't want to close
// the dialog in order to give the user the possibility to
// retry.
- logger.debug("The sign in operation has failed.");
+ if (logger.isDebugEnabled())
+ logger.debug("The sign in operation has failed.");

            if \(e\.getErrorCode\(\)
                    == OperationFailedException\.ILLEGAL\_ARGUMENT\)

@@ -403,7 +405,8 @@
// If the sign in operation has failed we don't want to close
// the dialog in order to give the user the possibility to
// retry.
- logger.debug("The sign in operation has failed.");
+ if (logger.isDebugEnabled())
+ logger.debug("The sign in operation has failed.");

            loadErrorMessage\(GuiActivator\.getResources\(\)\.getI18NString\(
                            &quot;service\.gui\.ACCOUNT\_CREATION\_FAILED&quot;,

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationComponent.java 2010-06-03 09:04:07+0000
@@ -174,7 +174,8 @@
}
catch (IllegalArgumentException e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

@@ -182,7 +183,8 @@
}
catch (NullPointerException e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

@@ -190,7 +192,8 @@
}
catch (UnsupportedOperationException e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

@@ -198,7 +201,8 @@
}
catch (SecurityException e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

@@ -206,7 +210,8 @@
}
catch (IOException e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

@@ -214,7 +219,8 @@
}
catch (Exception e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

        this\.showErrorMessage\(
            resources\.getI18NString\(

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java 2010-06-03 09:04:07+0000
@@ -2011,7 +2011,8 @@
{
ChatFocusEvent evt = new ChatFocusEvent(this, eventID);

- logger.trace("Will dispatch the following chat event: " + evt);
+ if (logger.isTraceEnabled())
+ logger.trace("Will dispatch the following chat event: " + evt);

    Iterable&lt;ChatFocusListener&gt; listeners;
    synchronized \(focusListeners\)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransferHandler.java 2010-06-03 09:04:07+0000
@@ -124,11 +124,13 @@
}
catch (UnsupportedFlavorException e)
{
- logger.debug("Failed to drop files.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop files.", e);
}
catch (IOException e)
{
- logger.debug("Failed to drop files.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop files.", e);
}
}
else if (t.isDataFlavorSupported(uiContactDataFlavor))
@@ -141,11 +143,13 @@
}
catch (UnsupportedFlavorException e)
{
- logger.debug("Failed to drop meta contact.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop meta contact.", e);
}
catch (IOException e)
{
- logger.debug("Failed to drop meta contact.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop meta contact.", e);
}

        if \(o instanceof ContactNode\)

@@ -219,11 +223,13 @@
}
catch (UnsupportedFlavorException ufe)
{
- logger.debug("Failed to drop string.", ufe);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop string.", ufe);
}
catch (IOException ioe)
{
- logger.debug("Failed to drop string.", ioe);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop string.", ioe);
}
}
return false;

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java 2010-06-03 09:04:07+0000
@@ -139,7 +139,8 @@
}
}

- logger.debug( "Could not find contact for menu item "
+ if (logger.isDebugEnabled())
+ logger.debug( "Could not find contact for menu item "
+ menuItem.getText() + ". contactsTable("
+ transportMenuItems.size()+") is : "
+ transportMenuItems);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java 2010-06-03 09:04:07+0000
@@ -345,7 +345,8 @@
*/
public void removeChat(ChatPanel chatPanel)
{
- logger.debug("Removes chat for contact: "
+ if (logger.isDebugEnabled())
+ logger.debug("Removes chat for contact: "
+ chatPanel.getChatSession().getChatName());

    //if there&#39;s no tabs remove the chat panel directly from the content

@@ -390,7 +391,8 @@
*/
public void removeAllChats()
{
- logger.debug("Remove all tabs from the chat window.");
+ if (logger.isDebugEnabled())
+ logger.debug("Remove all tabs from the chat window.");

    if\(getChatTabCount\(\) &gt; 0\)
    \{

@@ -415,7 +417,8 @@
{
ChatSession chatSession = chatPanel.getChatSession();

- logger.debug("Set current chat panel to: " + chatSession.getChatName());
+ if (logger.isDebugEnabled())
+ logger.debug("Set current chat panel to: " + chatSession.getChatName());

    if\(getChatTabCount\(\) &gt; 0\)
        this\.chatTabbedPane\.setSelectedComponent\(chatPanel\);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java 2010-06-03 09:04:07+0000
@@ -533,7 +533,8 @@
}
catch (MalformedURLException e)
{
- logger.debug("Could not locate image.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Could not locate image.", e);
}
}
return bytes;

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java 2010-06-03 09:04:07+0000
@@ -149,7 +149,8 @@
{
ChatRoom sourceChatRoom = (ChatRoom) evt.getSource();

- logger.trace(
+ if (logger.isTraceEnabled())
+ logger.trace(
"MESSAGE DELIVERED to chat room: " + sourceChatRoom.getName());

    ChatPanel chatPanel = GuiActivator\.getUIService\(\)\.getChatWindowManager\(\)

@@ -211,7 +212,8 @@
break;
}

- logger.trace("MESSAGE RECEIVED from contact: "
+ if (logger.isTraceEnabled())
+ logger.trace("MESSAGE RECEIVED from contact: "
+ sourceMember.getContactAddress());

    Message message = evt\.getMessage\(\);

@@ -1022,11 +1024,13 @@
}
catch (InterruptedException e)
{
- logger.trace("FindRoomTask has been interrupted.", e);
+ if (logger.isTraceEnabled())
+ logger.trace("FindRoomTask has been interrupted.", e);
}
catch (ExecutionException e)
{
- logger.trace("Execution exception occurred in FindRoomTask.", e);
+ if (logger.isTraceEnabled())
+ logger.trace("Execution exception occurred in FindRoomTask.", e);
}

    if \(chatRoom \!= null\)

@@ -1130,11 +1134,13 @@
}
catch (InterruptedException e)
{
- logger.trace("FindAllRoomsTask has been interrupted.", e);
+ if (logger.isTraceEnabled())
+ logger.trace("FindAllRoomsTask has been interrupted.", e);
}
catch (ExecutionException e)
{
- logger.trace("Execution exception occurred in FindAllRoomsTask", e);
+ if (logger.isTraceEnabled())
+ logger.trace("Execution exception occurred in FindAllRoomsTask", e);
}

    return chatRooms;

@@ -1436,7 +1442,8 @@
}
catch (OperationFailedException e)
{
- logger.trace("Failed to join chat room: "
+ if (logger.isTraceEnabled())
+ logger.trace("Failed to join chat room: "
+ chatRoom.getName(), e);

            switch \(e\.getErrorCode\(\)\)

@@ -1572,7 +1579,8 @@
}
catch (OperationFailedException e)
{
- logger.trace("Failed to join ad-hoc chat room: "
+ if (logger.isTraceEnabled())
+ logger.trace("Failed to join ad-hoc chat room: "
+ chatRoom.getName(), e);

            switch \(e\.getErrorCode\(\)\)

@@ -1685,7 +1693,8 @@
}
catch (Exception e)
{
- logger.trace("Un exception occurred while searching for room:"
+ if (logger.isTraceEnabled())
+ logger.trace("Un exception occurred while searching for room:"
+ chatRoomName, e);
}

@@ -1729,12 +1738,14 @@
}
catch (OperationFailedException e)
{
- logger.trace("Failed to obtain existing chat rooms for server: "
+ if (logger.isTraceEnabled())
+ logger.trace("Failed to obtain existing chat rooms for server: "
+ protocolProvider.getAccountID().getService(), e);
}
catch (OperationNotSupportedException e)
{
- logger.trace("Failed to obtain existing chat rooms for server: "
+ if (logger.isTraceEnabled())
+ logger.trace("Failed to obtain existing chat rooms for server: "
+ protocolProvider.getAccountID().getService(), e);
}

@@ -1750,7 +1761,8 @@
*/
public void invitationReceived(AdHocChatRoomInvitationReceivedEvent evt)
{
- logger.info("Invitation received: "+evt.toString());
+ if (logger.isInfoEnabled())
+ logger.info("Invitation received: "+evt.toString());
OperationSetAdHocMultiUserChat multiUserChatOpSet
= evt.getSourceOperationSet();

@@ -1773,7 +1785,8 @@
{
AdHocChatRoom sourceChatRoom = (AdHocChatRoom) evt.getSource();

- logger.info("MESSAGE DELIVERED to ad-hoc chat room: "
+ if (logger.isInfoEnabled())
+ logger.info("MESSAGE DELIVERED to ad-hoc chat room: "
+ sourceChatRoom.getName());

    ChatPanel chatPanel

@@ -1909,7 +1922,8 @@
break;
}

- logger.info("MESSAGE RECEIVED from contact: "
+ if (logger.isInfoEnabled())
+ logger.info("MESSAGE RECEIVED from contact: "
+ sourceParticipant.getAddress());

    Message message = evt\.getMessage\(\);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/FileTransferConversationComponent.java 2010-06-03 09:04:07+0000
@@ -362,7 +362,8 @@
}
catch (IllegalArgumentException e)
{
- logger.debug("Unable to open folder.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open folder.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

@@ -370,7 +371,8 @@
}
catch (NullPointerException e)
{
- logger.debug("Unable to open folder.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open folder.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

@@ -378,7 +380,8 @@
}
catch (UnsupportedOperationException e)
{
- logger.debug("Unable to open folder.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open folder.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

@@ -386,7 +389,8 @@
}
catch (SecurityException e)
{
- logger.debug("Unable to open folder.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open folder.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

@@ -394,7 +398,8 @@
}
catch (IOException e)
{
- logger.debug("Unable to open folder.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open folder.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

@@ -402,7 +407,8 @@
}
catch (Exception e)
{
- logger.debug("Unable to open file.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to open file.", e);

            this\.showErrorMessage\(
                resources\.getI18NString\(

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/filetransfer/ReceiveFileConversationComponent.java 2010-06-03 09:04:07+0000
@@ -164,13 +164,15 @@
logger.error("Could not create the download directory : "
+ downloadDir.getAbsolutePath());
}
- logger.debug("Download directory created : "
+ if (logger.isDebugEnabled())
+ logger.debug("Download directory created : "
+ downloadDir.getAbsolutePath());
}
}
catch (IOException e)
{
- logger.debug("Unable to find download directory.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to find download directory.", e);
}

    downloadFile = new File\(downloadDir, incomingFileName\);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/configforms/ConfigurationFrame.java 2010-06-03 09:04:07+0000
@@ -188,7 +188,8 @@
switch (event.getType())
{
case ServiceEvent.REGISTERED:
- logger.info("Handling registration of a new Configuration Form.");
+ if (logger.isInfoEnabled())
+ logger.info("Handling registration of a new Configuration Form.");

        this\.addConfigurationForm\(configForm\);
        break;

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java 2010-06-03 09:04:07+0000
@@ -228,7 +228,8 @@
*/
public void messageReceived(MessageReceivedEvent evt)
{
- logger.trace("MESSAGE RECEIVED from contact: "
+ if (logger.isTraceEnabled())
+ logger.trace("MESSAGE RECEIVED from contact: "
+ evt.getSourceContact().getAddress());

    Contact protocolContact = evt\.getSourceContact\(\);

@@ -309,7 +310,8 @@
}
else
{
- logger.trace("MetaContact not found for protocol contact: "
+ if (logger.isTraceEnabled())
+ logger.trace("MetaContact not found for protocol contact: "
+ protocolContact + ".");
}
}
@@ -325,7 +327,8 @@
MetaContact metaContact = GuiActivator.getContactListService()
.findMetaContactByContact(contact);

- logger.trace("MESSAGE DELIVERED to contact: " + contact.getAddress());
+ if (logger.isTraceEnabled())
+ logger.trace("MESSAGE DELIVERED to contact: " + contact.getAddress());

    ChatPanel chatPanel
        = chatWindowManager\.getContactChat\(metaContact, false\);

@@ -336,7 +339,8 @@
ProtocolProviderService protocolProvider
= contact.getProtocolProvider();

- logger.trace(
+ if (logger.isTraceEnabled())
+ logger.trace(
"MESSAGE DELIVERED: process message to chat for contact: "
+ contact.getAddress()
+ " MESSAGE: " + msg.getContent());

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTransferHandler.java 2010-06-03 09:04:07+0000
@@ -127,11 +127,13 @@
}
catch (UnsupportedFlavorException e)
{
- logger.debug("Failed to drop files.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop files.", e);
}
catch (IOException e)
{
- logger.debug("Failed to drop files.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Failed to drop files.", e);
}

        if \(o instanceof Collection\)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java 2010-06-03 09:04:07+0000
@@ -1048,7 +1048,8 @@
}
catch (InterruptedException e)
{
- logger.debug("Filter thread was interrupted.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Filter thread was interrupted.", e);
}
}
}
@@ -1742,7 +1743,8 @@
.createUIGroup(parentGroup);
}

- logger.info("Add matching contact due to status change: "
+ if (logger.isInfoEnabled())
+ logger.info("Add matching contact due to status change: "
+ uiContact.getDisplayName());
addContact(uiContact, uiGroup, true);
}
@@ -1754,7 +1756,8 @@
{
if (currentFilter != null && !currentFilter.isMatching(uiContact))
{
- logger.info("Remove unmatching contact due to status change: "
+ if (logger.isInfoEnabled())
+ logger.info("Remove unmatching contact due to status change: "
+ uiContact.getDisplayName());
removeContact(uiContact);
}

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java 2010-06-03 09:04:07+0000
@@ -132,7 +132,8 @@
ProtocolProviderService protocolProvider = evt.getProvider();
AccountID accountID = protocolProvider.getAccountID();

- logger.trace("Protocol provider: " + protocolProvider
+ if (logger.isTraceEnabled())
+ logger.trace("Protocol provider: " + protocolProvider
+ " changed its state to: " + evt.getNewState().getStateName());

    if \(newState\.equals\(RegistrationState\.REGISTERED\)\)

@@ -188,7 +189,8 @@
msgText).showDialog();
}

- logger.trace(evt.getReason());
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
}
// CONNECTION_FAILED events are now dispatched in reconnect plugin
// else if (newState.equals(RegistrationState.CONNECTION_FAILED))
@@ -271,7 +273,8 @@
.getI18NString("service.gui.ERROR"),
msgText).showDialog();
}
- logger.trace(evt.getReason());
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
}
}
}
@@ -321,7 +324,8 @@
*/
private void handleProviderAdded(ProtocolProviderService protocolProvider)
{
- logger.trace("The following protocol provider was just added: "
+ if (logger.isTraceEnabled())
+ logger.trace("The following protocol provider was just added: "
+ protocolProvider.getAccountID().getAccountAddress());

    protocolProvider\.addRegistrationStateChangeListener\(this\);

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java 2010-06-03 09:04:07+0000
@@ -201,7 +201,8 @@
OperationSetPresence presence
= MainFrame.getProtocolPresenceOpSet(protocolProvider);

- logger.trace("Update status for provider: "
+ if (logger.isTraceEnabled())
+ logger.trace("Update status for provider: "
+ protocolProvider.getAccountID().getAccountAddress()
+ ". The new status will be: " + presenceStatus.getStatusName());

Modified: trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java&p2=trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/utils/FileImageLabel.java 2010-06-03 09:04:07+0000
@@ -119,7 +119,8 @@
}
catch (MalformedURLException e)
{
- logger.debug("Could not locate image.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Could not locate image.", e);
this.setIcon(new ImageIcon(
ImageLoader.getImage(ImageLoader.DEFAULT_FILE_ICON)));
}

Modified: trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java&p2=trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java 2010-06-03 09:04:07+0000
@@ -1447,7 +1447,8 @@
}
catch (URISyntaxException e)
{
- logger.debug("Unable to parse image URL to URI.", e);
+ if (logger.isDebugEnabled())
+ logger.debug("Unable to parse image URL to URI.", e);
}

    return null;

Modified: trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java&p2=trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java (original)
+++ trunk/src/net/java/sip/communicator/impl/history/HistoryServiceImpl.java 2010-06-03 09:04:07+0000
@@ -287,7 +287,8 @@
{
// get the history directory corresponding the given id
File dir = this.createHistoryDirectories(id);
- logger.trace("Removing history directory " + dir);
+ if (logger.isTraceEnabled())
+ logger.trace("Removing history directory " + dir);
deleteDirAndContent(dir);
}

@@ -382,7 +383,8 @@

    if\(\!oldDir\.renameTo\(newDir\)\)
    \{

- logger.info("Cannot move history!");
+ if (logger.isInfoEnabled())
+ logger.info("Cannot move history!");
throw new IOException("Cannot move history!");
}

Modified: trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java?view=diff&rev=7199&p1=trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java&p2=trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java&r1=7198&r2=7199

--- trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java (original)
+++ trunk/src/net/java/sip/communicator/impl/keybindings/KeybindingsActivator.java 2010-06-03 09:04:07+0000
@@ -33,7 +33,8 @@
{
if (this.keybindingsService == null)
{
- logger.debug("Service Impl: " + getClass().getName()
+ if (logger.isDebugEnabled())
+ logger.debug("Service Impl: " + getClass().getName()
+ " [ STARTED ]");
this.keybindingsService = new KeybindingsServiceImpl();
this.keybindingsService.start(context);

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: commits-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#2

Hi Matthieu,

you are right if the logging level includes info, and this
should not be the case in a production release later on.

Also resource use of the additional check in case the logging
level includes info is negligible compared to the overall
logging processing of logger.info (or similar) for example,
which includes additional formatting, check of log file
size etc.

The fixes for the logger usage are done using a script, otherwise
it would take very much time to do this for over 200 files and
approx. 1300 places where logging occurs (not counting warn and
error).

Regards,
Werner

···

Am 03.06.2010 14:12, schrieb Matthieu Casanova:

Hello Werner,
as it is a good idea to add guard around log usage, I think some
specific case shoud not be guarded.

When the log message is a static String, it doesn't involve
unnecessary resource consumption like String concatenation would do.
So adding that test here is a resource waste because the test will be
done twice, one in your guard, and the second time in the logger
itself
For example in
GuiActivator

if (logger.isInfoEnabled())
                logger.info("UI Service...[ STARTED ]");

should be replaced by
logger.info("UI Service...[ STARTED ]");

Matthieu

2010/6/3 <wernerd@dev.java.net>:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Hi,
in fact it was not exactly what I meant.
The fact is that when trying to log something, the first thing that
the logger will do before formatting is checking if the log level is
active or not. If it isn't, no formatting is done in the logger
So if the argument given to the logger is only a simple String,
calling the isXXXLevelEnabled() will always be redundant

Matthieu

···

2010/6/3 Werner Dittmann <Werner.Dittmann@t-online.de>:

Hi Matthieu,

you are right if the logging level includes info, and this
should not be the case in a production release later on.

Also resource use of the additional check in case the logging
level includes info is negligible compared to the overall
logging processing of logger.info (or similar) for example,
which includes additional formatting, check of log file
size etc.

The fixes for the logger usage are done using a script, otherwise
it would take very much time to do this for over 200 files and
approx. 1300 places where logging occurs (not counting warn and
error).

Regards,
Werner

Am 03.06.2010 14:12, schrieb Matthieu Casanova:

Hello Werner,
as it is a good idea to add guard around log usage, I think some
specific case shoud not be guarded.

When the log message is a static String, it doesn't involve
unnecessary resource consumption like String concatenation would do.
So adding that test here is a resource waste because the test will be
done twice, one in your guard, and the second time in the logger
itself
For example in
GuiActivator

if (logger.isInfoEnabled())
logger.info("UI Service...[ STARTED ]");

should be replaced by
logger.info("UI Service...[ STARTED ]");

Matthieu

2010/6/3 <wernerd@dev.java.net>:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net