Class ForensicLogger

java.lang.Object
org.ametys.core.trace.ForensicLogger
All Implemented Interfaces:
Observer, Prioritizable, Supporter<Event>, 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: Supporter
      Check if an element is supported
      Specified by:
      supports in interface Supporter<Event>
      Parameters:
      event - The element
      Returns:
      true if the element is supported, false otherwise
    • getPriority

      public int getPriority()
      Description copied from interface: Prioritizable
      Get the priority for the component. On components using Prioritizable interface, each implementation define the order. In most cases, less is the number, more prior is the component.
      Specified by:
      getPriority in interface Prioritizable
      Returns:
      the 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