TraceeContextLogger(TraceeContextLogBuilder traceeGsonContextLogBuilder, ContextLoggerConfiguration contextLoggerConfiguration) { this.contextLoggerConfiguration = contextLoggerConfiguration; this.traceeGsonContextLogBuilder = traceeGsonContextLogBuilder; initConnectors(); }
@Override public void logJson(Object... instancesToLog) { this.logJsonWithPrefixedMessage(null, instancesToLog); }
@Override public String createJson(Object... instancesToLog) { return propagateToContextLogBuilder(instancesToLog); }
@AroundInvoke public Object intercept(InvocationContext ctx) throws Exception { try { return ctx.proceed(); } catch (Exception e) { // now log context informations TraceeContextLogger.createDefault().logJsonWithPrefixedMessage("TRACEE EJB INTERCEPTOR CONTEXT LOGGING LISTENER : ", ImplicitContext.COMMON, ImplicitContext.TRACEE, ctx, e); throw e; } }
@Override public ContextLogger build() { return new TraceeContextLogger(createGsonLogBuilder(), contextLoggerConfiguration); }
@Override public void logJsonWithPrefixedMessage(String prefixedMessage, Object... instancesToLog) { this.connectorsWrapper.sendErrorReportToConnectors(prefixedMessage, createJson(instancesToLog)); }
public static ContextLogger createDefault() { return create().build(); }
/** * This method handles the wrapping of the incoming object and passes them to the context toJson builder implementation. * * @param instancesToLog an array of objects to wrap * @return the contextual toJson information as a String */ String propagateToContextLogBuilder(Object[] instancesToLog) { Object[] propagateArray = null; if (instancesToLog != null) { propagateArray = new Object[instancesToLog.length]; for (int i = 0; i < instancesToLog.length; i++) { propagateArray[i] = wrapInstance(instancesToLog[i]); } } return traceeGsonContextLogBuilder.logPassedContext(new PassedDataContextProvider(propagateArray)); }
return createInstance(contextLoggerConfiguration.getImplicitContextClassMap().get(instance)); Object wrappedInstance = createInstance(knownWrapperType); if (WrappedContextData.class.isAssignableFrom(knownWrapperType)) { ((WrappedContextData) wrappedInstance).setContextData(instance); if (wrapper.getWrappedInstanceType().isAssignableFrom(instance.getClass())) { try { WrappedContextData wrapperInstance = (WrappedContextData) createInstance(wrapper.getWrapperType()); wrapperInstance.setContextData(instance);
private void handleHttpServletRequest( HttpServletRequest servletRequest, HttpServletResponse servletResponse, Exception e) { TraceeContextLogger.createDefault().logJsonWithPrefixedMessage("TRACEE SERVLET ERROR CONTEXT LOGGING LISTENER : ", ImplicitContext.COMMON, ImplicitContext.TRACEE, servletRequest, servletResponse, e); }