Class LogEvent
java.lang.Object
org.jpos.util.LogEvent
- Direct Known Subclasses:
FrozenLogEvent, MarkdownLogEvent
-
Constructor Summary
ConstructorsConstructorDescriptionLogEvent()Default constructor; uses theinfotag.Constructs an empty event with the given tag.Constructs an event with the given tag and an initial payload entry.Constructs an event tied to aLogSource.Constructs an event tied to aLogSourcewith an initial payload entry. -
Method Summary
Modifier and TypeMethodDescriptionAppends a payload entry and returns this event for chaining.voidaddMessage(Object msg) Adds a message or object to this event's payload.voidaddMessage(String tagname, String message) Adds a message wrapped in an XML tag to this event's payload.voiddump(PrintStream p, String outer) Dumps the full log event to the given PrintStream.protected StringdumpHeader(PrintStream p, String indent) Writes the log event header to the given PrintStream.protected voiddumpTrailer(PrintStream p, String indent) Writes the log event trailer to the given PrintStream.Returns the time at which this event was constructed.Returns the time at which this event was first dumped, capturing it on first call.WARNING: payLoad is a SynchronizedList.getRealm()Returns the realm of the associated source, or empty when no source is set.Returns theLogSourceassociated with this event, if any.getTag()Returns the log tag.getTags()Returns an unmodifiable view of this event's tags.Returns the current trace-id, generating one if absent.booleanIndicates whether the payload contains aThrowable.booleanThis is a hack for backward compatibility after accepting PR67voidsetNoArmor(boolean noArmor) Controls whether the XML wrapper is suppressed in log output.voidReplaces theLogSourceassociated with this event.voidSets the log tag for this event.toString()Renders this event to a string with no leading indent.Renders this event to a string with the given indent prefix.withSource(LogSource source) Sets theLogSourceassociated with this event and returns it for chaining.Adds or overwrites a tag on this event.Adds the supplied tags to this event.Ensures atrace-idtag is present, generating one if needed.withTraceId(String traceId) Sets thetrace-idtag explicitly.withTraceId(UUID uuid) Sets thetrace-idtag from a UUID (dashes stripped).
-
Constructor Details
-
LogEvent
-
LogEvent
public LogEvent()Default constructor; uses theinfotag. -
LogEvent
-
LogEvent
-
LogEvent
-
-
Method Details
-
getTag
-
setTag
-
addMessage
Adds a message or object to this event's payload.- Parameters:
msg- the message or object to add
-
addMessage
Adds a message wrapped in an XML tag to this event's payload.- Parameters:
tagname- the XML tag name to wrap the message inmessage- the message text
-
getSource
-
setSource
-
setNoArmor
Controls whether the XML wrapper is suppressed in log output.- Parameters:
noArmor- if true, suppress the XML wrapper
-
dumpHeader
Writes the log event header to the given PrintStream.- Parameters:
p- the PrintStream to write the header toindent- the indentation prefix- Returns:
- the inner indentation string for nested content
-
dumpTrailer
Writes the log event trailer to the given PrintStream.- Parameters:
p- the PrintStream to write the trailer toindent- the indentation prefix
-
dump
Dumps the full log event to the given PrintStream.- Parameters:
p- the PrintStream to dump toouter- the outer indentation string
-
getRealm
-
withTraceId
Sets thetrace-idtag explicitly.- Parameters:
traceId- trace identifier- Returns:
- this event for chaining
-
withTraceId
Sets thetrace-idtag from a UUID (dashes stripped).- Parameters:
uuid- trace UUID- Returns:
- this event for chaining
-
withTag
-
withTags
-
getTags
-
withSource
Sets theLogSourceassociated with this event and returns it for chaining.- Parameters:
source- new source- Returns:
- this event for chaining
-
add
-
withTraceId
Ensures atrace-idtag is present, generating one if needed.- Returns:
- this event for chaining
-
getTraceId
Returns the current trace-id, generating one if absent.- Returns:
- the trace-id (never
null)
-
getPayLoad
WARNING: payLoad is a SynchronizedList. If you intend to get a reference to it in order to iterate over the list, you need to synchronize on the returned object.synchronized (evt.getPayLoad()) { Iterator iter = evt.getPayLoad().iterator(); while (iter.hasNext()) { ... ... } }- Returns:
- payLoad, which is a SynchronizedList
-
toString
-
toString
-
hasException
-
isHonorSourceLogger
This is a hack for backward compatibility after accepting PR67- Returns:
- true if ISOSource has been set
- See Also:
-
getDumpedAt
Returns the time at which this event was first dumped, capturing it on first call.- Returns:
- the dump timestamp
-
getCreatedAt
Returns the time at which this event was constructed.- Returns:
- the creation timestamp
-