From: Roland Häder Date: Wed, 19 Oct 2022 15:08:05 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0544328c7965478e585be4b50781935bd7059d18;p=jcore-logger-ejb.git Continued: - also validate these parameters, e.g. please don't set 2nd parameter "cause" to NULL, but use the other method with one parameter instead! --- diff --git a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java index 74d63eb..36d208a 100644 --- a/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java +++ b/src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java @@ -50,78 +50,210 @@ public class LoggerBean implements LoggerBeanLocal { @Override public void logDebug (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().debug(message); } @Override public void logDebug (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().debug(message, cause); } @Override public void logError (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().error(message); } @Override public void logError (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().error(message, cause); } @Override public void logException (final Throwable throwable) { + // Validate parameter + if (null == throwable) { + // Throw NPE again + throw new NullPointerException("throwable is null"); //NOI18N + } + // Deligate to logger this.getLogger().catching(throwable); } @Override public void logFatal (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().fatal(message, cause); } @Override public void logFatal (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().fatal(message); } @Override public void logInfo (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().info(message); } @Override public void logInfo (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().info(message, cause); } @Override public void logTrace (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().trace(message); } @Override public void logTrace (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().trace(message, cause); } @Override public void logWarning (final String message) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } + // Deligate to logger this.getLogger().warn(message); } @Override public void logWarning (final String message, final Throwable cause) { + // Validate parameters + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } else if (message.isEmpty()) { + // Throw IAE + throw new IllegalArgumentException("message is empty"); //NOI18N + } else if (null == cause) { + // Throw NPE again + throw new NullPointerException("cause is null"); //NOI18N + } + // Deligate to logger this.getLogger().warn(message, cause); }