Class Slf4jInvocationEventEmitter

java.lang.Object
com.fayupable.logged.spring.emitter.Slf4jInvocationEventEmitter
All Implemented Interfaces:
InvocationEventEmitter

public class Slf4jInvocationEventEmitter extends Object implements InvocationEventEmitter
Default InvocationEventEmitter that writes each event as a single, human-readable line through SLF4J.

Successful calls are logged at INFO, failed calls at WARN, since a failure surfacing through a @Logged method is operationally significant even though the exception itself already propagates to the caller. The exception message is never included, only its simple class name, consistent with MethodInvocationEvent.

The trace id and depth carried by the event are only appended to the log line when MethodInvocationEvent.depth() is greater than zero, that is, when the call is part of a chain of nested @Logged invocations. Root-level, non-nested calls are logged without this extra detail, keeping the common case concise.

  • Constructor Details

    • Slf4jInvocationEventEmitter

      public Slf4jInvocationEventEmitter()
  • Method Details

    • emit

      public void emit(MethodInvocationEvent event)
      Description copied from interface: InvocationEventEmitter
      Publishes the given invocation event to whatever sink this implementation targets.

      Implementations must not throw checked or unchecked exceptions that would propagate back into the intercepted method call. Emission failures (for example a logging backend being unavailable) should be handled internally by the implementation.

      Specified by:
      emit in interface InvocationEventEmitter
      Parameters:
      event - the invocation event to publish, never null