@Override public boolean supports(RESTEasyTracingInfoFormat format) { if (format.equals(RESTEasyTracingInfoFormat.JSON)) return true; else return false; }
@Override public void flush(final MultivaluedMap<String, Object> headers) { final String[] messages = tracingInfo.getMessages(); for (int i = 0; i < messages.length; i++) { headers.putSingle(String.format(RESTEasyTracing.HEADER_RESPONSE_FORMAT, i), messages[i]); } } }
private void logImpl(final RESTEasyTracingEvent event, final long duration, final Object... messageArgs) { if (isEnabled(event.level())) { final String[] messageArgsStr = new String[messageArgs.length]; for (int i = 0; i < messageArgs.length; i++) { messageArgsStr[i] = formatInstance(messageArgs[i]); } final RESTEasyTracingMessage message = new RESTEasyTracingMessage(event, duration, messageArgsStr); tracingInfo.addMessage(message); final Logger.Level loggingLevel; switch (event.level()) { case SUMMARY: loggingLevel = Logger.Level.INFO; break; case TRACE: loggingLevel = Logger.Level.DEBUG; break; case VERBOSE: loggingLevel = Logger.Level.TRACE; break; default: loggingLevel = Logger.Level.INFO; } if (logger.isEnabled(loggingLevel)) { logger.log(loggingLevel, event.name() + ' ' + message.toString() + " [" + tracingInfo.formatDuration(duration) + " ms]"); } } }
/** * Get application-wide tracing level threshold. * * @return tracing level threshold. */ static RESTEasyTracingLevel getRESTEasyTracingThreshold(Configuration configuration) { final Object thresholdText = configuration.getProperty(ResteasyContextParameters.RESTEASY_TRACING_THRESHOLD); return (thresholdText == null) ? RESTEasyTracing.DEFAULT_LEVEL : RESTEasyTracingLevel.valueOf((String) thresholdText); }
/** * Get application-wide tracing level threshold. * @param configuration configuration * @return tracing level threshold. */ static String getTracingThreshold(Configuration configuration) { return TRACING.AVAILABLE ? RESTEasyTracingUtils.getRESTEasyTracingThreshold(configuration).toString() : null; } }
@Override public boolean isLogEnabled(final RESTEasyTracingEvent event) { return isEnabled(event.level()); }
RESTEasyTracingLoggerImpl(final RESTEasyTracingLevel threshold, final String loggerNameSuffix, final String format) { this.threshold = threshold; if (loggerNameSuffix != null) { this.logger = Logger.getLogger(TRACING_LOGGER_NAME_PREFIX + "." + loggerNameSuffix); } else { this.logger = Logger.getLogger(TRACING_LOGGER_NAME_PREFIX + "." + DEFAULT_LOGGER_NAME_SUFFIX); } tracingInfo = RESTEasyTracingInfo.get(format); }
/** * Return configuration type of tracing support according to application configuration. * <p> * By default tracing support is switched OFF. * @param configuration configuration * @return the configuration type */ static String getTracingConfig(Configuration configuration) { return TRACING.AVAILABLE ? RESTEasyTracingUtils.getRESTEasyTracingConfig(configuration).toString() : null; }
/** * Return configuration type of tracing support according to application configuration. * <p> * By default tracing support is switched OFF. */ static RESTEasyTracingConfig getRESTEasyTracingConfig(Configuration configuration) { final Object tracingText = configuration.getProperty(ResteasyContextParameters.RESTEASY_TRACING_TYPE); final RESTEasyTracingConfig result; if (tracingText != null) { result = RESTEasyTracingConfig.valueOf((String) tracingText); } else { result = RESTEasyTracingConfig.OFF; } return result; }
@Override public boolean supports(RESTEasyTracingInfoFormat format) { if (format.equals(RESTEasyTracingInfoFormat.JSON)) return true; else return false; }
static RESTEasyTracingLogger create(String tracingThreshold, String tracingLoggerNameSuffix, String tracingInfoFormat) { if (!TRACING.AVAILABLE) { return EMPTY; } return new RESTEasyTracingLoggerImpl(RESTEasyTracingLevel.valueOf(tracingThreshold), tracingLoggerNameSuffix, tracingInfoFormat); }
static String getTracingThreshold(RESTEasyTracingLevel appThreshold, HttpRequest request) { final String thresholdText = getHeaderString(request, RESTEasyTracing.HEADER_THRESHOLD); return (thresholdText == null) ? appThreshold.toString() : thresholdText; }
@Override public long timestamp(final RESTEasyTracingEvent event) { if (isEnabled(event.level())) { return System.nanoTime(); } return -1; }
RESTEasyTracingLoggerImpl(final RESTEasyTracingLevel threshold, final String loggerNameSuffix, final String format) { this.threshold = threshold; if (loggerNameSuffix != null) { this.logger = Logger.getLogger(TRACING_LOGGER_NAME_PREFIX + "." + loggerNameSuffix); } else { this.logger = Logger.getLogger(TRACING_LOGGER_NAME_PREFIX + "." + DEFAULT_LOGGER_NAME_SUFFIX); } tracingInfo = RESTEasyTracingInfo.get(format); }
@Override public boolean supports(RESTEasyTracingInfoFormat format) { if (format.equals(RESTEasyTracingInfoFormat.TEXT)) return true; else return false; }
static RESTEasyTracingLogger create(String tracingThreshold, String tracingLoggerNameSuffix, String tracingInfoFormat) { if (!TRACING.AVAILABLE) { return EMPTY; } return new RESTEasyTracingLoggerImpl(RESTEasyTracingLevel.valueOf(tracingThreshold), tracingLoggerNameSuffix, tracingInfoFormat); }
/** * Get application-wide tracing level threshold. * @param configuration configuration * @return tracing level threshold. */ static String getTracingThreshold(Configuration configuration) { return TRACING.AVAILABLE ? RESTEasyTracingUtils.getRESTEasyTracingThreshold(configuration).toString() : null; } }
@Override public void logDuration(final RESTEasyTracingEvent event, final long fromTimestamp, final Object... args) { if (isEnabled(event.level())) { final long toTimestamp; if (fromTimestamp == -1) { toTimestamp = -1; } else { toTimestamp = System.nanoTime(); } long duration = 0; if ((fromTimestamp != -1) && (toTimestamp != -1)) { duration = toTimestamp - fromTimestamp; } logImpl(event, duration, args); } }