diff options
4 files changed, 367 insertions, 735 deletions
diff --git a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java index 0a42343c6..995b9dea4 100644 --- a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java @@ -17,14 +17,9 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.certsrv.logging; -import java.text.MessageFormat; import java.util.LinkedHashMap; -import java.util.Locale; import java.util.Map; -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.MessageFormatter; - /** * The log event object that carries message detail of a log event * that goes into the Transaction log. Note that the name of this @@ -35,7 +30,7 @@ import com.netscape.certsrv.base.MessageFormatter; * @see java.text.MessageFormat * @see com.netscape.certsrv.logging.LogResources */ -public class AuditEvent implements IBundleLogEvent { +public class AuditEvent extends LogEvent { public final static String AUDIT_LOG_STARTUP = "LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP_2"; @@ -219,24 +214,9 @@ public class AuditEvent implements IBundleLogEvent { "LOGGING_SIGNED_AUDIT_SIGNING_3"; private static final long serialVersionUID = -844306657733902324L; - private static final String INVALID_LOG_LEVEL = "log level: {0} is invalid, should be 0-6"; - protected Object mParams[] = null; protected Map<String, Object> attributes = new LinkedHashMap<>(); - private String mEventType = null; - private String mMessage = null; - private int mLevel = -1; - private int mNTEventType = -1; - private LogSource mSource; - private boolean mMultiline = false; - private long mTimeStamp = System.currentTimeMillis(); - - /** - * The bundle name for this event. - */ - private String mBundleName = LogResources.class.getName(); - /** * Constructs a message event * <P> @@ -244,8 +224,7 @@ public class AuditEvent implements IBundleLogEvent { * @param msgFormat the message string */ public AuditEvent(String msgFormat) { - mMessage = msgFormat; - mParams = null; + super(msgFormat); } /** @@ -260,9 +239,7 @@ public class AuditEvent implements IBundleLogEvent { * @param param message string parameter */ public AuditEvent(String msgFormat, String param) { - this(msgFormat); - mParams = new String[1]; - mParams[0] = param; + super(msgFormat, param); } /** @@ -283,9 +260,7 @@ public class AuditEvent implements IBundleLogEvent { * @param exception system exception */ public AuditEvent(String msgFormat, Exception exception) { - this(msgFormat); - mParams = new Exception[1]; - mParams[0] = exception; + super(msgFormat, exception); } /** @@ -304,13 +279,7 @@ public class AuditEvent implements IBundleLogEvent { * @param e CMS exception */ public AuditEvent(Exception e) { - this(e.getMessage()); - if (e instanceof EBaseException) { - mParams = ((EBaseException) e).getParameters(); - } else { - mParams = new Exception[1]; - mParams[0] = e; - } + super(e); } /** @@ -322,215 +291,7 @@ public class AuditEvent implements IBundleLogEvent { * @param params list of message format parameters */ public AuditEvent(String msgFormat, Object params[]) { - this(msgFormat); - mParams = params; - } - - /** - * Returns the current message format string. - * <P> - * - * @return details message - */ - public String getMessage() { - return mMessage; - } - - /** - * Returns a list of parameters. - * <P> - * - * @return list of message format parameters - */ - public Object[] getParameters() { - return mParams; - } - - /** - * Sets audit event's parameters. - */ - public void setParameters(Object[] params) { - mParams = params; - } - - /** - * Returns localized message string. This method should - * only be called if a localized string is necessary. - * <P> - * - * @return details message - */ - public String toContent() { - return toContent(Locale.getDefault()); - } - - /** - * Returns the string based on the given locale. - * <P> - * - * @param locale locale - * @return details message - */ - public String toContent(Locale locale) { - return MessageFormatter.getLocalizedString(locale, getBundleName(), - getMessage(), - getParameters()); - } - - /** - * Gets the resource bundle name for this class instance. This should - * be overridden by subclasses who have their own resource bundles. - * - * @param bundle String that represents the resource bundle name to be set - */ - public void setBundleName(String bundle) { - mBundleName = bundle; - } - - /** - * Retrieves bundle name. - * - * @return a String that represents the resource bundle name - */ - protected String getBundleName() { - return mBundleName; - } - - /** - * Retrieves log source. - * - * @return the component source - * where this message event was triggered - */ - public LogSource getSource() { - return mSource; - } - - /** - * Sets log source. - * - * @param source the component source - * where this message event was triggered - */ - public void setSource(LogSource source) { - mSource = source; - } - - /** - * Retrieves log level. - * The log level of an event represents its relative importance - * or severity within CMS. - * - * @return Integer log level value. - */ - public int getLevel() { - return mLevel; - } - - /** - * Retrieves NT specific log event type. - * - * @return Integer NTEventType value. - */ - public int getNTEventType() { - return mNTEventType; - } - - /** - * Sets log level, NT log event type. - * For certain log levels the NT log event type gets - * set as well. - * - * @param level Integer log level value. - */ - public void setLevel(int level) { - mLevel = level; - switch (level) { - case ILogger.LL_DEBUG: - case ILogger.LL_INFO: - mNTEventType = ILogger.NT_INFO; - break; - - case ILogger.LL_WARN: - mNTEventType = ILogger.NT_WARN; - break; - - case ILogger.LL_FAILURE: - case ILogger.LL_MISCONF: - case ILogger.LL_CATASTRPHE: - case ILogger.LL_SECURITY: - mNTEventType = ILogger.NT_ERROR; - break; - - default: - ConsoleError.send(new SystemEvent(INVALID_LOG_LEVEL, - Integer.toString(level))); - break; - } - } - - /** - * Retrieves log multiline attribute. - * - * @return Boolean whether or not this event is multiline. - * A multiline message simply consists of more than one line. - */ - public boolean getMultiline() { - return mMultiline; - } - - /** - * Sets log multiline attribute. A multiline message consists of - * more than one line. - * - * @param multiline Boolean multiline value. - */ - public void setMultiline(boolean multiline) { - mMultiline = multiline; - } - - /** - * Retrieves event time stamp. - * - * @return Long integer of the time the event was created. - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Retrieves log event type. Each type of event - * has an associated String type value. - * - * @return String containing the type of event. - */ - public String getEventType() { - return mEventType; - } - - /** - * Sets log event type. Each type of event - * has an associated String type value. - * - * @param eventType String containing the type of event. - */ - public void setEventType(String eventType) { - mEventType = eventType; - } - - /** - * Return string representation of log message. - * - * @return String containing log message. - */ - public String toString() { - if (getBundleName() == null) { - MessageFormat detailMessage = new MessageFormat(mMessage); - - return detailMessage.format(mParams); - //return getMessage(); - } else - return toContent(); + super(msgFormat, params); } public void setAttribute(String name, Object value) { diff --git a/base/common/src/com/netscape/certsrv/logging/LogEvent.java b/base/common/src/com/netscape/certsrv/logging/LogEvent.java new file mode 100644 index 000000000..892f3d2f8 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/logging/LogEvent.java @@ -0,0 +1,349 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program 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 for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2017 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.logging; + +import java.text.MessageFormat; +import java.util.Locale; + +import com.netscape.certsrv.base.EBaseException; +import com.netscape.certsrv.base.MessageFormatter; + +public class LogEvent implements IBundleLogEvent { + + private static final long serialVersionUID = 1L; + + static final String INVALID_LOG_LEVEL = "log level: {0} is invalid, should be 0-6"; + + Object mParams[]; + + String mEventType; + String mMessage; + int mLevel = -1; + int mNTEventType = -1; + LogSource mSource; + boolean mMultiline = false; + long mTimeStamp = System.currentTimeMillis(); + + /** + * The bundle name for this event. + */ + String mBundleName = LogResources.class.getName(); + + public LogEvent() { + } + + /** + * Constructs a message event + * <P> + * + * @param msgFormat the message string + */ + public LogEvent(String msgFormat) { + mMessage = msgFormat; + mParams = null; + } + + /** + * Constructs a message with a parameter. For example, + * + * <PRE> + * new AuditEvent("failed to load {0}", fileName); + * </PRE> + * <P> + * + * @param msgFormat details in message string format + * @param param message string parameter + */ + public LogEvent(String msgFormat, String param) { + this(msgFormat); + mParams = new String[1]; + mParams[0] = param; + } + + /** + * Constructs a message from an exception. It can be used to carry + * a system exception that may contain information about + * the context. For example, + * + * <PRE> + * try { + * ... + * } catch (IOExeption e) { + * logHandler.log(new AuditEvent("Encountered System Error {0}", e); + * } + * </PRE> + * <P> + * + * @param msgFormat exception details in message string format + * @param exception system exception + */ + public LogEvent(String msgFormat, Exception exception) { + this(msgFormat); + mParams = new Exception[1]; + mParams[0] = exception; + } + + /** + * Constructs a message from a base exception. This will use the msgFormat + * from the exception itself. + * + * <PRE> + * try { + * ... + * } catch (Exception e) { + * logHandler.log(new AuditEvent(e)); + * } + * </PRE> + * <P> + * + * @param e CMS exception + */ + public LogEvent(Exception e) { + this(e.getMessage()); + if (e instanceof EBaseException) { + mParams = ((EBaseException) e).getParameters(); + } else { + mParams = new Exception[1]; + mParams[0] = e; + } + } + + /** + * Constructs a message event with a list of parameters + * that will be substituted into the message format. + * <P> + * + * @param msgFormat message string format + * @param params list of message format parameters + */ + public LogEvent(String msgFormat, Object params[]) { + this(msgFormat); + mParams = params; + } + + /** + * Returns the current message format string. + * <P> + * + * @return details message + */ + public String getMessage() { + return mMessage; + } + + public void setMessage(String message) { + this.mMessage = message; + } + + /** + * Returns a list of parameters. + * <P> + * + * @return list of message format parameters + */ + public Object[] getParameters() { + return mParams; + } + + /** + * Sets audit event's parameters. + */ + public void setParameters(Object[] params) { + mParams = params; + } + + /** + * Returns localized message string. This method should + * only be called if a localized string is necessary. + * <P> + * + * @return details message + */ + public String toContent() { + return toContent(Locale.getDefault()); + } + + /** + * Returns the string based on the given locale. + * <P> + * + * @param locale locale + * @return details message + */ + public String toContent(Locale locale) { + return MessageFormatter.getLocalizedString(locale, getBundleName(), + getMessage(), + getParameters()); + } + + /** + * Gets the resource bundle name for this class instance. This should + * be overridden by subclasses who have their own resource bundles. + * + * @param bundle String that represents the resource bundle name to be set + */ + public void setBundleName(String bundle) { + mBundleName = bundle; + } + + /** + * Retrieves bundle name. + * + * @return a String that represents the resource bundle name + */ + protected String getBundleName() { + return mBundleName; + } + + /** + * Retrieves log source. + * + * @return the component source + * where this message event was triggered + */ + public LogSource getSource() { + return mSource; + } + + /** + * Sets log source. + * + * @param source the component source + * where this message event was triggered + */ + public void setSource(LogSource source) { + mSource = source; + } + + /** + * Retrieves log level. + * The log level of an event represents its relative importance + * or severity within CMS. + * + * @return Integer log level value. + */ + public int getLevel() { + return mLevel; + } + + /** + * Retrieves NT specific log event type. + * + * @return Integer NTEventType value. + */ + public int getNTEventType() { + return mNTEventType; + } + + /** + * Sets log level, NT log event type. + * For certain log levels the NT log event type gets + * set as well. + * + * @param level Integer log level value. + */ + public void setLevel(int level) { + mLevel = level; + switch (level) { + case ILogger.LL_DEBUG: + case ILogger.LL_INFO: + mNTEventType = ILogger.NT_INFO; + break; + + case ILogger.LL_WARN: + mNTEventType = ILogger.NT_WARN; + break; + + case ILogger.LL_FAILURE: + case ILogger.LL_MISCONF: + case ILogger.LL_CATASTRPHE: + case ILogger.LL_SECURITY: + mNTEventType = ILogger.NT_ERROR; + break; + + default: + ConsoleError.send(new SystemEvent(INVALID_LOG_LEVEL, + Integer.toString(level))); + break; + } + } + + /** + * Retrieves log multiline attribute. + * + * @return Boolean whether or not this event is multiline. + * A multiline message simply consists of more than one line. + */ + public boolean getMultiline() { + return mMultiline; + } + + /** + * Sets log multiline attribute. A multiline message consists of + * more than one line. + * + * @param multiline Boolean multiline value. + */ + public void setMultiline(boolean multiline) { + mMultiline = multiline; + } + + /** + * Retrieves event time stamp. + * + * @return Long integer of the time the event was created. + */ + public long getTimeStamp() { + return mTimeStamp; + } + + /** + * Retrieves log event type. Each type of event + * has an associated String type value. + * + * @return String containing the type of event. + */ + public String getEventType() { + return mEventType; + } + + /** + * Sets log event type. Each type of event + * has an associated String type value. + * + * @param eventType String containing the type of event. + */ + public void setEventType(String eventType) { + mEventType = eventType; + } + + /** + * Return string representation of log message. + * + * @return String containing log message. + */ + public String toString() { + if (getBundleName() == null) { + MessageFormat detailMessage = new MessageFormat(mMessage); + + return detailMessage.format(mParams); + //return getMessage(); + } else + return toContent(); + } +} diff --git a/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java b/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java index c9adb3f85..08f9e7f64 100644 --- a/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java @@ -17,12 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.certsrv.logging; -import java.text.MessageFormat; -import java.util.Locale; - -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.MessageFormatter; - /** * The log event object that carries message detail of a log event * that goes into the Signed Audit Event log. This log has the @@ -33,31 +27,10 @@ import com.netscape.certsrv.base.MessageFormatter; * @see java.text.MessageFormat * @see com.netscape.certsrv.logging.LogResources */ -public class SignedAuditEvent implements IBundleLogEvent { +public class SignedAuditEvent extends LogEvent { - /** - * - */ private static final long serialVersionUID = 4287822756516673931L; - protected Object mParams[] = null; - - private String mEventType = null; - private String mMessage = null; - private int mLevel = -1; - private int mNTEventType = -1; - private LogSource mSource; - private boolean mMultiline = false; - private long mTimeStamp = System.currentTimeMillis(); - - private static final String INVALID_LOG_LEVEL = "log level: {0} is invalid, should be 0-6"; - - /** - * The bundle name for this event. - * ....not anymore...keep for now and clean up later - */ - private String mBundleName = LogResources.class.getName(); - /** * Constructs a SignedAuditEvent message event. * <P> @@ -65,8 +38,7 @@ public class SignedAuditEvent implements IBundleLogEvent { * @param msgFormat The message string. */ public SignedAuditEvent(String msgFormat) { - mMessage = msgFormat; - mParams = null; + super(msgFormat); } /** @@ -81,9 +53,7 @@ public class SignedAuditEvent implements IBundleLogEvent { * @param param Message string parameter. */ public SignedAuditEvent(String msgFormat, String param) { - this(msgFormat); - mParams = new String[1]; - mParams[0] = param; + super(msgFormat, param); } /** @@ -104,9 +74,7 @@ public class SignedAuditEvent implements IBundleLogEvent { * @param exception System exception. */ public SignedAuditEvent(String msgFormat, Exception exception) { - this(msgFormat); - mParams = new Exception[1]; - mParams[0] = exception; + super(msgFormat, exception); } /** @@ -125,13 +93,7 @@ public class SignedAuditEvent implements IBundleLogEvent { * @param e CMS exception. */ public SignedAuditEvent(Exception e) { - this(e.getMessage()); - if (e instanceof EBaseException) { - mParams = ((EBaseException) e).getParameters(); - } else { - mParams = new Exception[1]; - mParams[0] = e; - } + super(e); } /** @@ -143,207 +105,6 @@ public class SignedAuditEvent implements IBundleLogEvent { * @param params List of message format parameters. */ public SignedAuditEvent(String msgFormat, Object params[]) { - this(msgFormat); - mParams = params; - } - - /** - * Returns the current message format string. - * <P> - * - * @return Details message. - */ - public String getMessage() { - return mMessage; - } - - /** - * Returns a list of parameters. These parameters can be - * used to assist in formatting the message. - * <P> - * - * @return List of message format parameters. - */ - public Object[] getParameters() { - return mParams; - } - - /** - * Returns localized message string. This method should - * only be called if a localized string is necessary. - * <P> - * - * @return Details message. - */ - public String toContent() { - return toContent(Locale.getDefault()); - } - - /** - * Returns the string based on the given locale. - * <P> - * - * @param locale Locale. - * @return Details message. - */ - public String toContent(Locale locale) { - return MessageFormatter.getLocalizedString(locale, getBundleName(), - getMessage(), - getParameters()); - } - - /** - * Sets the resource bundle name for this class instance. This should - * be overridden by subclasses who have their own resource bundles. - * - * @param bundle String with name of resource bundle. - */ - public void setBundleName(String bundle) { - mBundleName = bundle; - } - - /** - * Retrieves bundle name. - * - * @return String with name of resource bundle. - */ - protected String getBundleName() { - return mBundleName; - } - - /** - * Retrieves log source. - * This is the subsystem responsible - * for creating the log event. - * - * @return LogSource log source. - */ - public LogSource getSource() { - return mSource; - } - - /** - * Sets log source. - * - * @param source log source. - */ - public void setSource(LogSource source) { - mSource = source; - } - - /** - * Retrieves log level. - * The log level of an event represents its relative importance - * or severity within CMS. - * - * @return Integer log level value. - */ - public int getLevel() { - return mLevel; - } - - /** - * Retrieves NT specific log event type. - * - * @return Integer NTEventType value. - */ - public int getNTEventType() { - return mNTEventType; - } - - /** - * Sets log level, NT log event type. - * For certain log levels the NT log event type gets - * set as well. - * - * @param level Integer log level value. - */ - public void setLevel(int level) { - mLevel = level; - switch (level) { - case ILogger.LL_DEBUG: - case ILogger.LL_INFO: - mNTEventType = ILogger.NT_INFO; - break; - - case ILogger.LL_WARN: - mNTEventType = ILogger.NT_WARN; - break; - - case ILogger.LL_FAILURE: - case ILogger.LL_MISCONF: - case ILogger.LL_CATASTRPHE: - case ILogger.LL_SECURITY: - mNTEventType = ILogger.NT_ERROR; - break; - - default: - ConsoleError.send(new SignedAuditEvent(INVALID_LOG_LEVEL, - Integer.toString(level))); - break; - } - } - - /** - * Retrieves log multiline attribute. - * - * @return Boolean whether or not this event is multiline. - * A multiline message simply consists of more than one line. - */ - public boolean getMultiline() { - return mMultiline; - } - - /** - * Sets log multiline attribute. A multiline message consists of - * more than one line. - * - * @param multiline Boolean multiline value. - */ - public void setMultiline(boolean multiline) { - mMultiline = multiline; - } - - /** - * Retrieves event time stamp. - * - * @return Long integer of the time the event was created. - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Retrieves log event type. Each type of event - * has an associated String type value. - * - * @return String containing the type of event. - */ - public String getEventType() { - return mEventType; - } - - /** - * Sets log event type. Each type of event - * has an associated String type value. - * - * @param eventType String containing the type of event. - */ - public void setEventType(String eventType) { - mEventType = eventType; - } - - /** - * Return string representation of log message. - * - * @return String containing log message. - */ - public String toString() { - if (getBundleName() == null) { - MessageFormat detailMessage = new MessageFormat(mMessage); - - return detailMessage.format(mParams); - } else - return toContent(); + super(msgFormat, params); } } diff --git a/base/common/src/com/netscape/certsrv/logging/SystemEvent.java b/base/common/src/com/netscape/certsrv/logging/SystemEvent.java index 96f944c38..5e914f075 100644 --- a/base/common/src/com/netscape/certsrv/logging/SystemEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/SystemEvent.java @@ -17,12 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.certsrv.logging; -import java.text.MessageFormat; -import java.util.Locale; - -import com.netscape.certsrv.base.EBaseException; -import com.netscape.certsrv.base.MessageFormatter; - /** * The log event object that carries a log message. * This class represents System events which are CMS events @@ -32,30 +26,10 @@ import com.netscape.certsrv.base.MessageFormatter; * @see java.text.MessageFormat * @see com.netscape.certsrv.logging.LogResources */ -public class SystemEvent implements IBundleLogEvent { +public class SystemEvent extends LogEvent { - /** - * - */ private static final long serialVersionUID = 7160410535724580752L; - protected Object mParams[] = null; - - private String mEventType = null; - private String mMessage = null; - private int mLevel = -1; - private int mNTEventType = -1; - private LogSource mSource; - private boolean mMultiline = false; - private long mTimeStamp = System.currentTimeMillis(); - - /** - * The bundle name for this event. - */ - private String mBundleName = LogResources.class.getName(); - - private static final String INVALID_LOG_LEVEL = "log level: {0} is invalid, should be 0-6"; - /** * Constructs a SystemEvent message event. * <P> @@ -63,8 +37,7 @@ public class SystemEvent implements IBundleLogEvent { * @param msgFormat The message string. */ public SystemEvent(String msgFormat) { - mMessage = msgFormat; - mParams = null; + super(msgFormat); } /** @@ -79,9 +52,7 @@ public class SystemEvent implements IBundleLogEvent { * @param param Message string parameter. */ public SystemEvent(String msgFormat, String param) { - this(msgFormat); - mParams = new String[1]; - mParams[0] = param; + super(msgFormat, param); } /** @@ -102,9 +73,7 @@ public class SystemEvent implements IBundleLogEvent { * @param exception System exception. */ public SystemEvent(String msgFormat, Exception exception) { - this(msgFormat); - mParams = new Exception[1]; - mParams[0] = exception; + super(msgFormat, exception); } /** @@ -123,13 +92,7 @@ public class SystemEvent implements IBundleLogEvent { * @param e CMS exception. */ public SystemEvent(Exception e) { - this(e.getMessage()); - if (e instanceof EBaseException) { - mParams = ((EBaseException) e).getParameters(); - } else { - mParams = new Exception[1]; - mParams[0] = e; - } + super(e); } /** @@ -141,208 +104,6 @@ public class SystemEvent implements IBundleLogEvent { * @param params List of message format parameters. */ public SystemEvent(String msgFormat, Object params[]) { - this(msgFormat); - mParams = params; - } - - /** - * Returns the current message format string. - * <P> - * - * @return Details message. - */ - public String getMessage() { - return mMessage; - } - - /** - * Returns a list of parameters. These parameters can be - * used to assist in formatting the message. - * <P> - * - * @return List of message format parameters. - */ - public Object[] getParameters() { - return mParams; - } - - /** - * Returns localized message string. This method should - * only be called if a localized string is necessary. - * <P> - * - * @return Details message. - */ - public String toContent() { - return toContent(Locale.getDefault()); - } - - /** - * Returns the string based on the given locale. - * <P> - * - * @param locale Locale. - * @return Details message. - */ - public String toContent(Locale locale) { - return MessageFormatter.getLocalizedString(locale, getBundleName(), - getMessage(), - getParameters()); - } - - /** - * Sets the resource bundle name for this class instance. This should - * be overridden by subclasses who have their own resource bundles. - * - * @param bundle String with the name of resource bundle. - */ - public void setBundleName(String bundle) { - mBundleName = bundle; - } - - /** - * Retrieves bundle name. - * - * @return String with name of resource bundle. - */ - protected String getBundleName() { - return mBundleName; - } - - /** - * Retrieves log source. - * This is the subsystem responsible - * for creating the log event. - * - * @return log source. - */ - public LogSource getSource() { - return mSource; - } - - /** - * Sets log source. - * Sets the id of the subsystem issuing the event. - * - * @param source log source. - */ - public void setSource(LogSource source) { - mSource = source; - } - - /** - * Retrieves log level. - * The log level of an event represents its relative importance - * or severity within CMS. - * - * @return Integer log level value. - */ - public int getLevel() { - return mLevel; - } - - /** - * Retrieves NT specific log event type. - * - * @return Integer NTEventType value. - */ - public int getNTEventType() { - return mNTEventType; - } - - /** - * Sets log level, NT log event type. - * For certain log levels the NT log event type gets - * set as well. - * - * @param level Integer log level value. - */ - public void setLevel(int level) { - mLevel = level; - switch (level) { - case ILogger.LL_DEBUG: - case ILogger.LL_INFO: - mNTEventType = ILogger.NT_INFO; - break; - - case ILogger.LL_WARN: - mNTEventType = ILogger.NT_WARN; - break; - - case ILogger.LL_FAILURE: - case ILogger.LL_MISCONF: - case ILogger.LL_CATASTRPHE: - case ILogger.LL_SECURITY: - mNTEventType = ILogger.NT_ERROR; - break; - - default: - ConsoleError.send(new SystemEvent(INVALID_LOG_LEVEL, - Integer.toString(level))); - break; - } - } - - /** - * Retrieves log multiline attribute. - * - * @return Boolean whether or not this event is multiline. - * A multiline message simply consists of more than one line. - */ - public boolean getMultiline() { - return mMultiline; - } - - /** - * Sets log multiline attribute. A multiline message consists of - * more than one line. - * - * @param multiline Boolean multiline value. - */ - public void setMultiline(boolean multiline) { - mMultiline = multiline; - } - - /** - * Retrieves event time stamp. - * - * @return Long integer of the time the event was created. - */ - public long getTimeStamp() { - return mTimeStamp; - } - - /** - * Retrieves log event type. Each type of event - * has an associated String type value. - * - * @return String containing the type of event. - */ - public String getEventType() { - return mEventType; - } - - /** - * Sets log event type. Each type of event - * has an associated String type value. - * - * @param eventType String containing the type of event. - */ - public void setEventType(String eventType) { - mEventType = eventType; - } - - /** - * Return string representation of log message. - * - * @return String containing log message. - */ - public String toString() { - if (getBundleName() == null) { - MessageFormat detailMessage = new MessageFormat(mMessage); - - return detailMessage.format(mParams); - } else - return toContent(); + super(msgFormat, params); } } |