Class ForensicLogger

java.lang.Object
org.ametys.core.trace.ForensicLogger
All Implemented Interfaces:
Observer, Contextualizable

public class ForensicLogger extends Object implements Observer, Contextualizable
This class is an observer and a helper to trace all forensic events
  • Constructor Details

  • Method Details

    • contextualize

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • getLogger

      public static Logger getLogger(String eventId)
      Get the logger of a given event ID for tracing.
      Parameters:
      eventId - The event identifier.
      Returns:
      The logger corresponding to the event
    • supports

      public boolean supports(Event event)
      Description copied from interface: Observer
      Checks if the event is supported. If true, the observe(Event) method will be called.
      Specified by:
      supports in interface Observer
      Parameters:
      event - the event.
      Returns:
      true for observing this event, false otherwise.
    • getPriority

      public int getPriority(Event event)
      Description copied from interface: Observer
      Retrieves the priority to observe this event.
      This can be used to process a supported event before others observers.
      Specified by:
      getPriority in interface Observer
      Parameters:
      event - the event.
      Returns:
      the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
    • observe

      public void observe(Event event, Map<String,Object> transientVars) throws Exception
      Description copied from interface: Observer
      Observes an event.
      Specified by:
      observe in interface Observer
      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

      public static void info(String eventId, Map<String,Object> eventArgs, UserIdentity issuer)
      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 id
      eventArgs - the event arguments
      issuer - the issuer. Can be null.
    • warn

      public static void warn(String eventId, Map<String,Object> eventArgs, UserIdentity issuer)
      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 id
      eventArgs - the event arguments
      issuer - the issuer. Can be null.
    • getIP

      public static String getIP()
      Get IP from request
      Returns:
      the IP or [unknown] if there is no request
    • requestHeaders

      public static String requestHeaders()
      Get the request headers to log
      Returns:
      the request headers
    • eventIssuer

      public static String eventIssuer(UserIdentity user)
      Get readable value of issuer
      Parameters:
      user - the user. Can be null
      Returns:
      the issuer to display in logs
    • eventArguments

      public static String eventArguments(Map<String,Object> arguments)
      Build message for event arguments
      Parameters:
      arguments - the arguments
      Returns:
      the message to trace for arguments