use of com.teamscale.jacoco.agent.options.JacocoAgentBuilder in project teamscale-jacoco-agent by cqse.
the class AgentBase method premain.
/**
* Called by the actual premain method once the agent is isolated from the rest of the application.
*/
public static void premain(String options, Instrumentation instrumentation) throws Exception {
AgentOptions agentOptions;
DelayedLogger delayedLogger = new DelayedLogger();
try {
agentOptions = AgentOptionsParser.parse(options, delayedLogger);
} catch (AgentOptionParseException e) {
try (LoggingUtils.LoggingResources ignored = initializeFallbackLogging(options, delayedLogger)) {
delayedLogger.error("Failed to parse agent options: " + e.getMessage(), e);
System.err.println("Failed to parse agent options: " + e.getMessage());
// we perform actual logging output after writing to console to
// ensure the console is reached even in case of logging issues
// (see TS-23151). We use the Agent class here (same as below)
Logger logger = LoggingUtils.getLogger(Agent.class);
delayedLogger.logTo(logger);
throw e;
}
}
loggingResources = LoggingUtils.initializeLogging(agentOptions.getLoggingConfig());
Logger logger = LoggingUtils.getLogger(Agent.class);
delayedLogger.logTo(logger);
HttpUtils.setShouldValidateSsl(agentOptions.shouldValidateSsl());
logger.info("Starting JaCoCo's agent");
JacocoAgentBuilder agentBuilder = new JacocoAgentBuilder(agentOptions);
org.jacoco.agent.rt.internal_3570298.PreMain.premain(agentBuilder.createJacocoAgentOptions(), instrumentation);
AgentBase agent = agentBuilder.createAgent(instrumentation);
agent.registerShutdownHook();
}
Aggregations