|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.LoggableImpl
public class LoggableImpl
Implements code common to all Exceptions.
The two base exceptions BaseException
and BaseRuntimeException and the
LogEvent use a object of this class
as a member and delegate all common calls to this member.
This class also implements the special
Loggable that allows to add named
parameters and to get a more detailed logging, with an assigned
error message.
The error response id is used to mark log entries with an unique id. This id is also returned to the client (caller). If the client reports the error response id it can be used to find a specific log entries more quickly. If the nested exception has already an error response id, it is re-used for this exception and will not get a new one.
Functionality provided by this class is:ERROR_RESPONSE_ID parameter for each
instance.
| Field Summary | |
|---|---|
static String |
APPLICATION_NAME_PARAMETER_NAME
Name of the application of the loggable. |
static String |
CAUSE_PARAMETER_NAME
Key used for the root cause added to the loggable. |
static String |
CLASSNAME
Name of this class. |
static String |
CONTEXT_PARAMETER_PREFIX
Context parameter values prefix. |
static String |
EVENT_TIME_PARAMETER_NAME
Key used for the event time parameter of the loggable. |
static String |
GROUP_NAME_PARAMETER_NAME
Name of the group of the loggable. |
static String |
INSTANCE_ID
Id for this instance. |
static String |
INSTANCE_ID_PARAMETER_NAME
Key used for the instance id parameter object. |
static Logger |
logger
Logger used for this class. |
static String |
MESSAGE_INFO_PARAMETER_NAME
Key used for the log message info parameter object. |
static String |
NODE_ID
This nodes id. |
static String |
NODE_ID_PARAMETER_NAME
Key used for the node id parameter object. |
static org.jcoderz.commons.LoggableImpl.ThreadIdHolder |
THREAD_ID_GENERATOR
Virtual thread Id generated for this thread. |
static String |
THREAD_ID_PARAMETER_NAME
Key used for the thread id parameter object. |
static String |
THREAD_NAME_PARAMETER_NAME
Key used for the thread name parameter object. |
static String |
TRACKING_NUMBER_PARAMETER_NAME
Key used for the error response id added to the loggable. |
| Constructor Summary | |
|---|---|
LoggableImpl(Loggable outer,
LogMessageInfo errorId)
Create this loggable provide the 'Loggable' functionality for the given outer loggable. |
|
LoggableImpl(Loggable outer,
LogMessageInfo errorId,
long threadId,
String threadName,
String instanceId,
String nodeId)
Create this loggable provide the 'Loggable' functionality for the given outer loggable with the given dynamic parameters. |
|
LoggableImpl(Loggable outer,
LogMessageInfo errorId,
long threadId,
String threadName,
String instanceId,
String nodeId,
Throwable cause)
Create this loggable provide the 'Loggable' functionality for the given outer loggable with the given dynamic parameters and an initial cause.. |
|
LoggableImpl(Loggable outer,
LogMessageInfo errorId,
Throwable cause)
Create this loggable provide the 'Loggable' functionality for the given outer loggable with an initial cause. |
|
| Method Summary | |
|---|---|
void |
addParameter(String name,
Serializable value)
Adds a new named parameter. |
Throwable |
getCause()
Returns the cause of this throwable or null if the
cause is nonexistent or unknown. |
long |
getEventTime()
Returns the point in time when the event occurred. |
String |
getInstanceId()
Returns the instance identifier of the process that generated this Loggable. |
LogMessageInfo |
getLogMessageInfo()
Returns the LogMessageInfo for this Loggable. |
String |
getMessage()
Returns the (Detail) message of this loggable. |
String |
getNodeId()
Returns the ip-address or the host name where the Loggable was created. |
List |
getParameter(String name)
Returns a list of all parameters with the given name. |
Set |
getParameterNames()
Returns a set of available parameters. |
String |
getSourceClass()
Tries to find the source class name where this log event was fired. |
String |
getSourceMethod()
Tries to find the source method where this log event was fired. |
long |
getThreadId()
Returns the thread id of the thread that created this Loggable. |
String |
getThreadName()
Returns the thread name as it was valid at the time of creation of this Loggable. |
String |
getTrackingNumber()
Returns the (unique) tracking number of this Loggable instance. |
void |
initCause(Throwable cause)
Sets the cause of this throwable. |
void |
log()
Logs this Loggable into the appropriate log
sink. |
String |
toDetailedString()
The toString method of Loggable must dump out all
information stored within this loggable in a readable way. |
String |
toString()
The toString method of Loggable dumps the
String representation of the class name of the loggable
and the contained message. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String CLASSNAME
public static final Logger logger
public static final String MESSAGE_INFO_PARAMETER_NAME
public static final String TRACKING_NUMBER_PARAMETER_NAME
public static final String CAUSE_PARAMETER_NAME
public static final String THREAD_ID_PARAMETER_NAME
public static final String THREAD_NAME_PARAMETER_NAME
public static final String INSTANCE_ID_PARAMETER_NAME
public static final String NODE_ID_PARAMETER_NAME
public static final String EVENT_TIME_PARAMETER_NAME
public static final String APPLICATION_NAME_PARAMETER_NAME
public static final String GROUP_NAME_PARAMETER_NAME
public static final String CONTEXT_PARAMETER_PREFIX
public static final String NODE_ID
public static final String INSTANCE_ID
public static final org.jcoderz.commons.LoggableImpl.ThreadIdHolder THREAD_ID_GENERATOR
| Constructor Detail |
|---|
public LoggableImpl(Loggable outer,
LogMessageInfo errorId)
outer - the the outer loggable.errorId - the static LogMessageInfo for this Loggable.
public LoggableImpl(Loggable outer,
LogMessageInfo errorId,
Throwable cause)
outer - the the outer loggable.errorId - the static LogMessageInfo for this Loggable.cause - the cause of the outer.
public LoggableImpl(Loggable outer,
LogMessageInfo errorId,
long threadId,
String threadName,
String instanceId,
String nodeId)
outer - the the outer loggable.errorId - the static LogMessageInfo for this Loggable.threadId - the threadId to be set.threadName - the threadName to be set.instanceId - the instanceId to be set.nodeId - the nodeId to be set.
public LoggableImpl(Loggable outer,
LogMessageInfo errorId,
long threadId,
String threadName,
String instanceId,
String nodeId,
Throwable cause)
outer - the the outer loggable.errorId - the static LogMessageInfo for this Loggable.threadId - the threadId to be set.threadName - the threadName to be set.instanceId - the instanceId to be set.nodeId - the nodeId to be set.cause - the cause of the outer.| Method Detail |
|---|
public final void initCause(Throwable cause)
Throwable.initCause(Throwable) for the case
the super call fails.
cause - the cause of this Exception.
public final void addParameter(String name,
Serializable value)
name might occur several times.
addParameter in interface Loggablename - the name of the parameter.value - The value of the parameterpublic List getParameter(String name)
name must not start with an _
character. These are reserved for internal use.
getParameter in interface Loggablename - The name of the parameter to be retrieved.
public Set getParameterNames()
getParameterNames in interface Loggablepublic final LogMessageInfo getLogMessageInfo()
LogMessageInfo for this Loggable.
getLogMessageInfo in interface LoggableLogMessageInfo for this Loggable.public final String getTrackingNumber()
Loggable instance.
getTrackingNumber in interface LoggableLoggable instance.public final long getEventTime()
Loggable object was created.
getEventTime in interface Loggablepublic final String getNodeId()
getNodeId in interface Loggablepublic final String getInstanceId()
getInstanceId in interface Loggablepublic final long getThreadId()
Loggable.
getThreadId in interface LoggableLoggable.public final String getThreadName()
Loggable.
getThreadName in interface LoggableLoggable.Thread.getName()public Throwable getCause()
null if the
cause is nonexistent or unknown. (The cause is the throwable
that caused this throwable to get thrown.)
The returned object might be a Loggable.
getCause in interface Loggablenull if the
cause is nonexistent or unknown.public void log()
Loggable into the appropriate log
sink.
log in interface Loggablepublic String getMessage()
LogMessageInfo and parameters.
The field might get truncated on the presentation layer.
getMessage in interface Loggablepublic String getSourceClass()
getSourceClass in interface LoggableStackTraceElement.getClassName()public String getSourceMethod()
getSourceMethod in interface LoggableStackTraceElement.getMethodName(),
StackTraceElement.getLineNumber()public String toString()
Loggable dumps the
String representation of the class name of the loggable
and the contained message.
toString in interface LoggabletoString in class ObjectLoggable.public String toDetailedString()
Loggable must dump out all
information stored within this loggable in a readable way. This
includes the information of possible nested data.
toDetailedString in interface LoggableLoggable.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||