Package org.ametys.core.trace
Class ForensicLogger
java.lang.Object
org.ametys.core.trace.ForensicLogger
- All Implemented Interfaces:
Observer,Contextualizable
This class is an observer and a helper to trace all forensic events
-
Field Summary
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextualize(Context context) static StringeventArguments(Map<String, Object> arguments) Build message for event argumentsstatic StringeventIssuer(UserIdentity user) Get readable value of issuerstatic StringgetIP()Get IP from requeststatic LoggerGet the logger of a given event ID for tracing.intgetPriority(Event event) Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.static voidTrace event in INFO level to following format: [IP::127.0.0.1] [Issuer::login#population] event.id (arg1::value1|arg2::value2|...) (header1::value1|header2::value2|...)voidObserves an event.static StringGet the request headers to logbooleanChecks if the event is supported.static voidTrace event in WARN level to following format: [IP::127.0.0.1] [Issuer::login#population] event.id (arg1::value1|arg2::value2|...) (header1::value1|header2::value2|...)
-
Constructor Details
-
ForensicLogger
public ForensicLogger()
-
-
Method Details
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
getLogger
Get the logger of a given event ID for tracing.- Parameters:
eventId- The event identifier.- Returns:
- The logger corresponding to the event
-
supports
Description copied from interface:ObserverChecks if the event is supported. If true, the observe(Event) method will be called. -
getPriority
Description copied from interface:ObserverRetrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriorityin interfaceObserver- Parameters:
event- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
Description copied from interface:ObserverObserves an event.- Specified by:
observein interfaceObserver- Parameters:
event- the event.transientVars- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
info
Trace event in INFO level to following format: [IP::127.0.0.1] [Issuer::login#population] event.id (arg1::value1|arg2::value2|...) (header1::value1|header2::value2|...)- Parameters:
eventId- the event ideventArgs- the event argumentsissuer- the issuer. Can be null.
-
warn
Trace event in WARN level to following format: [IP::127.0.0.1] [Issuer::login#population] event.id (arg1::value1|arg2::value2|...) (header1::value1|header2::value2|...)- Parameters:
eventId- the event ideventArgs- the event argumentsissuer- the issuer. Can be null.
-
getIP
Get IP from request- Returns:
- the IP or [unknown] if there is no request
-
requestHeaders
Get the request headers to log- Returns:
- the request headers
-
eventIssuer
Get readable value of issuer- Parameters:
user- the user. Can be null- Returns:
- the issuer to display in logs
-
eventArguments
Build message for event arguments- Parameters:
arguments- the arguments- Returns:
- the message to trace for arguments
-