/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is a helper class that provides some conveniece methods wrapped around the
* standard {@link java.util.logging.Logger} interface.
*
* The class also makes sure that logger names of each Metro subsystem are consistent
* with each other.
*
* @author Marek Potociar <marek.potociar at sun.com>
* @author Fabian Ritzmann
*/
public class Logger {
//
//
/**
* Prevents creation of a new instance of this Logger unless used by a subclass.
*/
}
/**
* <p>
* The factory method returns preconfigured Logger wrapper for the class. Method calls
* {@link #getSystemLoggerName(java.lang.Class)} to generate default logger name.
* </p>
* <p>
* Since there is no caching implemented, it is advised that the method is called only once
* per a class in order to initialize a final static logger variable, which is then used
* through the class to perform actual logging tasks.
* </p>
*
* @param componentClass class of the component that will use the logger instance. Must not be {@code null}.
* @return logger instance preconfigured for use with the component
* @throws NullPointerException if the componentClass parameter is {@code null}.
*/
}
/**
* The factory method returns preconfigured Logger wrapper for the class. Since there is no caching implemented,
* it is advised that the method is called only once per a class in order to initialize a final static logger variable,
* which is then used through the class to perform actual logging tasks.
*
* This method should be only used in a special cases when overriding of a default logger name derived from the
* package of the component class is needed. For all common use cases please use {@link #getLogger(java.lang.Class)}
* method.
*
* @param customLoggerName custom name of the logger.
* @param componentClass class of the component that will use the logger instance. Must not be {@code null}.
* @return logger instance preconfigured for use with the component
* @throws NullPointerException if the componentClass parameter is {@code null}.
*
* @see #getLogger(java.lang.Class)
*/
public static @NotNull Logger getLogger(final @NotNull String customLoggerName, final @NotNull Class<?> componentClass) {
}
/**
* Calculates the subsystem suffix based on the package of the component class
* @param componentClass class of the component that will use the logger instance. Must not be {@code null}.
* @return system logger name for the given {@code componentClass} instance
*/
if (lastIndexOfWsPackage > -1) {
if (st.hasMoreTokens()) {
}
}
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
return;
}
}
public boolean isMethodCallLoggable() {
}
}
}
public void entering() {
return;
}
}
return;
}
}
public void exiting() {
return;
}
}
return;
}
}
/**
* Method logs {@code exception}'s message as a {@code SEVERE} logging level
* message.
* <p/>
* If {@code cause} parameter is not {@code null}, it is logged as well and
* {@code exception} original cause is initialized with instance referenced
* by {@code cause} parameter.
*
* @param exception exception whose message should be logged. Must not be
* {@code null}.
* @param cause initial cause of the exception that should be logged as well
* and set as {@code exception}'s original cause. May be {@code null}.
* @return the same exception instance that was passed in as the {@code exception}
* parameter.
*/
} else {
logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), exception.getMessage(), cause);
}
}
return exception;
}
/**
* Method logs {@code exception}'s message as a {@code SEVERE} logging level
* message.
* <p/>
* If {@code logCause} parameter is {@code true}, {@code exception}'s original
* cause is logged as well (if exists). This may be used in cases when
* {@code exception}'s class provides constructor to initialize the original
* cause. In such case you do not need to use
* {@link #logSevereException(Throwable, Throwable)}
* method version but you might still want to log the original cause as well.
*
* @param exception exception whose message should be logged. Must not be
* {@code null}.
* @param logCause deterimnes whether initial cause of the exception should
* be logged as well
* @return the same exception instance that was passed in as the {@code exception}
* parameter.
*/
logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), exception.getMessage(), exception.getCause());
} else {
}
}
return exception;
}
/**
* Same as {@link #logSevereException(Throwable, boolean) logSevereException(exception, true)}.
*/
} else {
logger.logp(Level.SEVERE, componentClassName, getCallerMethodName(), exception.getMessage(), exception.getCause());
}
}
return exception;
}
/**
* Method logs {@code exception}'s message at the logging level specified by the
* {@code level} argument.
* <p/>
* If {@code cause} parameter is not {@code null}, it is logged as well and
* {@code exception} original cause is initialized with instance referenced
* by {@code cause} parameter.
*
* @param exception exception whose message should be logged. Must not be
* {@code null}.
* @param cause initial cause of the exception that should be logged as well
* and set as {@code exception}'s original cause. May be {@code null}.
* @param level loging level which should be used for logging
* @return the same exception instance that was passed in as the {@code exception}
* parameter.
*/
public <T extends Throwable> T logException(final T exception, final Throwable cause, final Level level) {
} else {
}
}
return exception;
}
/**
* Method logs {@code exception}'s message at the logging level specified by the
* {@code level} argument.
* <p/>
* If {@code logCause} parameter is {@code true}, {@code exception}'s original
* cause is logged as well (if exists). This may be used in cases when
* {@code exception}'s class provides constructor to initialize the original
* cause. In such case you do not need to use
* {@link #logException(Throwable, Throwable, Level) logException(exception, cause, level)}
* method version but you might still want to log the original cause as well.
*
* @param exception exception whose message should be logged. Must not be
* {@code null}.
* @param logCause deterimnes whether initial cause of the exception should
* be logged as well
* @param level loging level which should be used for logging
* @return the same exception instance that was passed in as the {@code exception}
* parameter.
*/
public <T extends Throwable> T logException(final T exception, final boolean logCause, final Level level) {
logger.logp(level, componentClassName, getCallerMethodName(), exception.getMessage(), exception.getCause());
} else {
}
}
return exception;
}
/**
* Same as {@link #logException(Throwable, Throwable, Level)
* logException(exception, true, level)}.
*/
} else {
logger.logp(level, componentClassName, getCallerMethodName(), exception.getMessage(), exception.getCause());
}
}
return exception;
}
/**
* Function returns the name of the caller method for the method executing this
* function.
*
* @return caller method name from the call stack of the current {@link Thread}.
*/
return getStackMethodName(5);
}
/**
* Method returns the name of the method that is on the {@code methodIndexInStack}
* position in the call stack of the current {@link Thread}.
*
* @param methodIndexInStack index to the call stack to get the method name for.
* @return the name of the method that is on the {@code methodIndexInStack}
* position in the call stack of the current {@link Thread}.
*/
final String methodName;
} else {
methodName = "UNKNOWN METHOD";
}
return methodName;
}
}