@Override public void onThrowable(final Throwable t) { // Something wrong happened. logger.error("An error occurred while sending the error report via HTTP to '" + targetUrl + "'", t); } });
@Override public Response onCompleted(final Response response) throws Exception { logger.info("Error report send via HTTP to '" + targetUrl + "'"); return response; }
@Override public void log(final TraceeLogger logger, final String logMessage) { logger.debug(logMessage); } };
@Override public void log(final TraceeLogger logger, final String logMessage) { logger.warn(logMessage); } },
private static void logWarn(final String message) { Tracee.getBackend().getLoggerFactory().getLogger(TypeToWrapper.class).warn(message); } }
@Override public void log(final TraceeLogger logger, final String logMessage) { logger.error(logMessage); } },
@Override public void log(final TraceeLogger logger, final String logMessage) { logger.info(logMessage); } },
/** * Gets the profile defined via the system properties. * @return returns the profile defined via the system properties. Returns null if property is not set or set to an invalid value */ static Profile getProfileFromSystemProperties() { Profile result = null; // try to get system property String systemPropertyProfileName = System.getProperty(ProfilePropertyNames.PROFILE_SET_GLOBALLY_VIA_SYSTEM_PROPERTIES); if (systemPropertyProfileName != null) { // try to convert String to enum value try { result = Profile.valueOf(systemPropertyProfileName); } catch (IllegalArgumentException e) { Tracee.getBackend().getLoggerFactory().getLogger(Profile.class).warn("Tracee ContextLoggerBuilder profile property ('" + ProfilePropertyNames.PROFILE_SET_GLOBALLY_VIA_SYSTEM_PROPERTIES + "') is set to the invalid value '" + systemPropertyProfileName + "' ==> Use default profile"); } } return result; }
@Override public final void sendErrorReport(String json) { logger.error(json); } }
/** * Gets the profile defined via the system properties. * * @return returns the profile defined via the system properties. Returns null if property is not set or set to an invalid value */ static Profile getProfileFromSystemProperties() { Profile result = null; // try to get system property String systemPropertyProfileName = System.getProperty(ProfilePropertyNames.PROFILE_SET_GLOBALLY_VIA_SYSTEM_PROPERTIES); if (systemPropertyProfileName != null) { // try to convert String to enum value try { result = Profile.valueOf(systemPropertyProfileName); } catch (IllegalArgumentException e) { Tracee.getBackend().getLoggerFactory().getLogger(Profile.class).warn("Tracee ContextLoggerBuilder profile property ('" + ProfilePropertyNames.PROFILE_SET_GLOBALLY_VIA_SYSTEM_PROPERTIES + "') is set to the invalid value '" + systemPropertyProfileName + "' ==> Use default profile"); } } return result; }
@Override public final void sendErrorReport(String json) { logger.error(json); } }
/** * Gets the profile defined via the system properties. * @return returns the profile defined via the system properties or {@code null} if property is not set or set to an invalid value. */ static Profile getProfileFromFileInClasspath(final String filename) { Profile result = null; try { Properties properties = openProperties(filename); if (properties != null) { String profileFromProperties = properties.getProperty(ProfilePropertyNames.PROFILE_SET_BY_FILE_IN_CLASSPATH_PROPERTY); if (profileFromProperties != null) { // try to convert String to enum value try { result = Profile.valueOf(profileFromProperties); } catch (IllegalArgumentException e) { Tracee.getBackend().getLoggerFactory().getLogger(Profile.class).warn( "Tracee custom ContextLoggerBuilder profile property ('" + ProfilePropertyNames.PROFILE_SET_BY_FILE_IN_CLASSPATH_PROPERTY + "') is set to the invalid value '" + profileFromProperties + "' and will be ignored" ); } } } } catch (IOException e) { // ignore it } return result; }
/** * Tries to create a Connector for a given connector configuration name. * * @param connectorConfigurationName the name of the connector configuration * @return the connector if it could be created and initialized without error, otherwise null */ final Connector createConnector(final String connectorConfigurationName) { Map<String, String> propertyMap = this.getPropertiesForConnectorConfigurationName(connectorConfigurationName); String type = propertyMap.get(TraceeContextLoggerConstants.SYSTEM_PROPERTY_CONTEXT_LOGGER_CONNECTOR_TYPE); // get canonical class name for well known connectors if (WELL_KNOW_CONNECTOR_MAPPINGS.containsKey(type)) { type = WELL_KNOW_CONNECTOR_MAPPINGS.get(type); } try { // try to create connector instance Connector connector = (Connector) Class.forName(type).newInstance(); // now try to call init method connector.init(propertyMap); return connector; } catch (Exception e) { LOGGER.error("An error occurred while creating connector with name '" + connectorConfigurationName + "' of type '" + type + "'", e); } return null; }
/** * Gets the profile defined via the system properties. * * @return returns the profile defined via the system properties or {@code null} if property is not set or set to an invalid value. */ static Profile getProfileFromFileInClasspath(final String filename) { Profile result = null; try { Properties properties = openProperties(filename); if (properties != null) { String profileFromProperties = properties.getProperty(ProfilePropertyNames.PROFILE_SET_BY_FILE_IN_CLASSPATH_PROPERTY); if (profileFromProperties != null) { // try to convert String to enum value try { result = Profile.valueOf(profileFromProperties); } catch (IllegalArgumentException e) { Tracee.getBackend().getLoggerFactory().getLogger(Profile.class).warn( "Tracee custom ContextLoggerBuilder profile property ('" + ProfilePropertyNames.PROFILE_SET_BY_FILE_IN_CLASSPATH_PROPERTY + "') is set to the invalid value '" + profileFromProperties + "' and will be ignored" ); } } } } catch (IOException e) { // ignore it } return result; }
/** * Tries to create a Connector for a given connector configuration name. * * @param connectorConfigurationName the name of the connector configuration * @return the connector if it could be created and initialized without error, otherwise null */ final Connector createConnector(final String connectorConfigurationName) { Map<String, String> propertyMap = this.getPropertiesForConnectorConfigurationName(connectorConfigurationName); String type = propertyMap.get(TraceeContextLoggerConstants.SYSTEM_PROPERTY_CONTEXT_LOGGER_CONNECTOR_TYPE); // get canonical class name for well known connectors if (WELL_KNOW_CONNECTOR_MAPPINGS.containsKey(type)) { type = WELL_KNOW_CONNECTOR_MAPPINGS.get(type); } try { // try to create connector instance Connector connector = (Connector) Class.forName(type).newInstance(); // now try to call init method connector.init(propertyMap); return connector; } catch (Exception e) { LOGGER.error("An error occurred while creating connector with name '" + connectorConfigurationName + "' of type '" + type + "'", e); } return null; }
private static void logError(final String message, final Throwable e) { Tracee.getBackend().getLoggerFactory().getLogger(TypeToWrapper.class).error(message, e); }
@Override public final void sendErrorReport(final String json) { final String targetUrl = this.url; try { @SuppressWarnings("resource") final AsyncHttpClient asyncHttpClient = asyncHttpClientProvider.provideHttpClient(builder.build()); asyncHttpClient.preparePost(targetUrl).setBody(json).setHeader("Content-type", "text/json;charset=utf-8").setBodyEncoding("UTF-8") .execute(new AsyncCompletionHandler<Response>() { @Override public Response onCompleted(final Response response) throws Exception { logger.info("Error report send via HTTP to '" + targetUrl + "'"); return response; } @Override public void onThrowable(final Throwable t) { // Something wrong happened. logger.error("An error occurred while sending the error report via HTTP to '" + targetUrl + "'", t); } }); } catch (final IOException e) { logger.error("An error occurred while sending the error report via HTTP to '" + this.url + "'", e); } }