Package com.sos.i18n.logging.commons

Source Code of com.sos.i18n.logging.commons.CommonsLogMsg

/********************************************************* begin of preamble
**
** Copyright (C) 2003-2010 Software- und Organisations-Service GmbH.
** All rights reserved.
**
** This file may be used under the terms of either the
**
**   GNU General Public License version 2.0 (GPL)
**
**   as published by the Free Software Foundation
**   http://www.gnu.org/licenses/gpl-2.0.txt and appearing in the file
**   LICENSE.GPL included in the packaging of this file.
**
** or the
** 
**   Agreement for Purchase and Licensing
**
**   as offered by Software- und Organisations-Service GmbH
**   in the respective terms of supply that ship with this file.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
** POSSIBILITY OF SUCH DAMAGE.
********************************************************** end of preamble*/
/**
* I18N Messages and Logging
* Copyright (C) 2006 John J. Mazzitelli
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
package com.sos.i18n.logging.commons;

import com.sos.i18n.Logger;
import com.sos.i18n.Msg;
import com.sos.i18n.Msg.BundleBaseName;
import com.sos.i18n.exception.LocalizedException;
import com.sos.i18n.exception.LocalizedRuntimeException;
import java.util.Locale;
import org.apache.commons.logging.Log;

/**
* <p>This class provides alot of static methods to assist in logging localized messages via a commons logging log
* object.</p>
*
* <p>There is a method to the madness in the parameter ordering. Anytime you want to specify a localized message,
* you always specify the base bundle name first, followed by the locale, the bundle key and the variable list of
* arguments that go with the keyed message (all in that order). Bundle name and locale are both optional. This is
* consistent with the way localized messages are specified in constructors for {@link LocalizedException} and
* {@link LocalizedRuntimeException}. When you need to specify a <code>Throwable</code> with your localized
* message, it is specified before those parameters. Again, this is consistent both in this class and the localized
* exception classes (see {@link CommonsLogMsg#fatal(Log, Throwable, Msg.BundleBaseName, Locale, String, Object[])}
* and {@link LocalizedException#LocalizedException(Throwable, Msg.BundleBaseName, Locale, String, Object[])} as
* examples).</p>
*
* <p>These static utility methods respect the settings defined by {@link Logger#setDumpStackTraces(boolean)} and
* {@link Logger#setDumpLogKeys(boolean)}.</p>
*
* @author  <a href="mailto:jmazzitelli@users.sourceforge.net">John Mazzitelli</a>
* @version $Revision: 1.1 $
* @see     Msg
* @see     LocalizedException
* @see     LocalizedRuntimeException
*/
public class CommonsLogMsg
{
   /**
    * Prevents instantiation.
    */
   private CommonsLogMsg()
   {
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    *
    * @see    Msg#createMsg(com.sos.i18n.Msg.BundleBaseName, Locale, String, Object[])
    */
   public static Msg fatal( Log            log,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.fatal( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    *
    * @see    Msg#createMsg(com.sos.i18n.Msg.BundleBaseName, Locale, String, Object[])
    */
   public static Msg fatal( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logFatalWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log       log,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.fatal( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log       log,
                            Throwable throwable,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logFatalWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log            log,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.fatal( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logFatalWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log       log,
                            String    key,
                            Object... varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.fatal( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg fatal( Log       log,
                            Throwable throwable,
                            String    key,
                            Object... varargs )
   {
      if ( log.isFatalEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logFatalWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log            log,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.error( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logErrorWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log       log,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.error( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log       log,
                            Throwable throwable,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logErrorWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log            log,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.error( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logErrorWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log       log,
                            String    key,
                            Object... varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.error( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the error level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg error( Log       log,
                            Throwable throwable,
                            String    key,
                            Object... varargs )
   {
      if ( log.isErrorEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logErrorWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log            log,
                           BundleBaseName basename,
                           Locale         locale,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.warn( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log            log,
                           Throwable      throwable,
                           BundleBaseName basename,
                           Locale         locale,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logWarnWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log       log,
                           Locale    locale,
                           String    key,
                           Object... varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.warn( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log       log,
                           Throwable throwable,
                           Locale    locale,
                           String    key,
                           Object... varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logWarnWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log            log,
                           BundleBaseName basename,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.warn( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log            log,
                           Throwable      throwable,
                           BundleBaseName basename,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logWarnWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log       log,
                           String    key,
                           Object... varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.warn( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the warn level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg warn( Log       log,
                           Throwable throwable,
                           String    key,
                           Object... varargs )
   {
      if ( log.isWarnEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logWarnWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log            log,
                           BundleBaseName basename,
                           Locale         locale,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.info( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log            log,
                           Throwable      throwable,
                           BundleBaseName basename,
                           Locale         locale,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logInfoWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log       log,
                           Locale    locale,
                           String    key,
                           Object... varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.info( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log       log,
                           Throwable throwable,
                           Locale    locale,
                           String    key,
                           Object... varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logInfoWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log            log,
                           BundleBaseName basename,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.info( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log            log,
                           Throwable      throwable,
                           BundleBaseName basename,
                           String         key,
                           Object...      varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logInfoWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log       log,
                           String    key,
                           Object... varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.info( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the info level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg info( Log       log,
                           Throwable throwable,
                           String    key,
                           Object... varargs )
   {
      if ( log.isInfoEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logInfoWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log            log,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.debug( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logDebugWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log       log,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.debug( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log       log,
                            Throwable throwable,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logDebugWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log            log,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.debug( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logDebugWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log       log,
                            String    key,
                            Object... varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.debug( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the debug level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg debug( Log       log,
                            Throwable throwable,
                            String    key,
                            Object... varargs )
   {
      if ( log.isDebugEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logDebugWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  locale   the locale to determine what bundle to use
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log            log,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         log.trace( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            Locale         locale,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( basename, locale, key, varargs );
         logTraceWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  locale  the locale to determine what bundle to use
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log       log,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         log.trace( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  locale    the locale to determine what bundle to use
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log       log,
                            Throwable throwable,
                            Locale    locale,
                            String    key,
                            Object... varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( locale, key, varargs );
         logTraceWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log      the log where the messages will go
    * @param  basename the base name of the resource bundle
    * @param  key      the resource bundle key name
    * @param  varargs  arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log            log,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         log.trace( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  basename  the base name of the resource bundle
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log            log,
                            Throwable      throwable,
                            BundleBaseName basename,
                            String         key,
                            Object...      varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( basename, key, varargs );
         logTraceWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * @param  log     the log where the messages will go
    * @param  key     the resource bundle key name
    * @param  varargs arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log       log,
                            String    key,
                            Object... varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         log.trace( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg );
         return msg;
      }

      return null;
   }

   /**
    * Logs the given message to the log at the trace level. If the log level is not enabled, this method does
    * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned.
    *
    * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p>
    *
    * @param  log       the log where the messages will go
    * @param  throwable the throwable associated with the log message
    * @param  key       the resource bundle key name
    * @param  varargs   arguments to help fill in the resource bundle message
    *
    * @return if the message was logged, a non-<code>null</code> Msg object is returned
    */
   public static Msg trace( Log       log,
                            Throwable throwable,
                            String    key,
                            Object... varargs )
   {
      if ( log.isTraceEnabled() )
      {
         Msg msg = Msg.createMsg( key, varargs );
         logTraceWithThrowable( log, key, msg, throwable );
         return msg;
      }

      return null;
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the fatal level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, it doesn't matter. FATAL log level
    * messages should be very rare and normally indicate a very bad condition. In this case, we should always dump
    * the stack trace no matter how we are configured.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logFatalWithThrowable( Log       log,
                                              String    key,
                                              Msg       msg,
                                              Throwable throwable )
   {
      log.fatal( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the error level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
    * with the throwable's <code>Throwable.toString()</code> contents.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logErrorWithThrowable( Log       log,
                                              String    key,
                                              Msg       msg,
                                              Throwable throwable )
   {
      if ( Logger.getDumpStackTraces() )
      {
         log.error( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
      }
      else
      {
         log.error( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg )
                    + ". Cause: " + throwable.toString() );
      }
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the warn level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
    * with the throwable's <code>Throwable.toString()</code> contents.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logWarnWithThrowable( Log       log,
                                             String    key,
                                             Msg       msg,
                                             Throwable throwable )
   {
      if ( Logger.getDumpStackTraces() )
      {
         log.warn( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
      }
      else
      {
         log.warn( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg )
                   + ". Cause: " + throwable.toString() );
      }
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the info level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
    * with the throwable's <code>Throwable.toString()</code> contents.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logInfoWithThrowable( Log       log,
                                             String    key,
                                             Msg       msg,
                                             Throwable throwable )
   {
      if ( Logger.getDumpStackTraces() )
      {
         log.info( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
      }
      else
      {
         log.info( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg )
                   + ". Cause: " + throwable.toString() );
      }
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the debug level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
    * with the throwable's <code>Throwable.toString()</code> contents.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logDebugWithThrowable( Log       log,
                                              String    key,
                                              Msg       msg,
                                              Throwable throwable )
   {
      if ( Logger.getDumpStackTraces() )
      {
         log.debug( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
      }
      else
      {
         log.debug( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg )
                    + ". Cause: " + throwable.toString() );
      }
   }

   /**
    * Logs the message, along with the given <code>throwable</code>, at the trace level. If
    * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended
    * with the throwable's <code>Throwable.toString()</code> contents.
    *
    * @param log       where to log the message
    * @param key       the resource key that is associated with the message
    * @param msg       the message to log
    * @param throwable the throwable associated with the message
    */
   private static void logTraceWithThrowable( Log       log,
                                              String    key,
                                              Msg       msg,
                                              Throwable throwable )
   {
      if ( Logger.getDumpStackTraces() )
      {
         log.trace( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg ), throwable );
      }
      else
      {
         log.trace( ( ( Logger.getDumpLogKeys() ) ? ( '{' + key + '}' + msg ) : msg )
                    + ". Cause: " + throwable.toString() );
      }
   }
}
TOP

Related Classes of com.sos.i18n.logging.commons.CommonsLogMsg

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.