Package org.ametys.core.trace
Class ForensicLogger
java.lang.Object
org.ametys.core.trace.ForensicLogger
- All Implemented Interfaces:
Observer,Prioritizable,Supporter<Event>,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 org.slf4j.LoggerGet the logger of a given event ID for tracing.intGet the priority for the component.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 logbooleanCheck if an element is supportedstatic 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:SupporterCheck if an element is supported -
getPriority
Description copied from interface:PrioritizableGet the priority for the component. On components usingPrioritizableinterface, each implementation define the order. In most cases, less is the number, more prior is the component.- Specified by:
getPriorityin interfacePrioritizable- Returns:
- the 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
-