use of org.gradle.api.logging.configuration.ShowStacktrace in project gradle by gradle.
the class SetupTab method updateStackTraceSetting.
/**
* This stores the current stack trace setting (based on the UI controls) in the plugin.
*/
private void updateStackTraceSetting(boolean saveSetting) {
ShowStacktrace stackTraceLevel = getSelectedStackTraceLevel();
gradlePluginLord.setStackTraceLevel(stackTraceLevel);
if (saveSetting) {
settingsNode.setValueOfChild(STACK_TRACE_LEVEL, stackTraceLevel.name());
}
}
use of org.gradle.api.logging.configuration.ShowStacktrace in project gradle by gradle.
the class SetupTab method setSelectedStackTraceLevel.
/**
* Sets the selected strack trace level on the radio buttons. The radio buttons store their stack trace level as a client property and I'll look for a match using that. This way, we don't have to
* edit this if new levels are created.
*
* @param newStackTraceLevel the new stack trace level.
*/
private void setSelectedStackTraceLevel(ShowStacktrace newStackTraceLevel) {
Enumeration<AbstractButton> buttonEnumeration = stackTraceButtonGroup.getElements();
while (buttonEnumeration.hasMoreElements()) {
JRadioButton radioButton = (JRadioButton) buttonEnumeration.nextElement();
ShowStacktrace level = (ShowStacktrace) radioButton.getClientProperty(STACK_TRACE_LEVEL_CLIENT_PROPERTY);
if (newStackTraceLevel == level) {
radioButton.setSelected(true);
return;
}
}
}
use of org.gradle.api.logging.configuration.ShowStacktrace in project gradle by gradle.
the class DefaultGradleLauncherFactory method doNewInstance.
private DefaultGradleLauncher doNewInstance(StartParameter startParameter, GradleLauncher parent, BuildCancellationToken cancellationToken, BuildRequestMetaData requestMetaData, BuildEventConsumer buildEventConsumer, final BuildSessionScopeServices sessionScopeServices, List<?> servicesToStop) {
BuildScopeServices serviceRegistry = BuildScopeServices.forSession(sessionScopeServices);
serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
serviceRegistry.add(BuildEventConsumer.class, buildEventConsumer);
serviceRegistry.add(BuildCancellationToken.class, cancellationToken);
NestedBuildFactoryImpl nestedBuildFactory = new NestedBuildFactoryImpl(sessionScopeServices);
serviceRegistry.add(NestedBuildFactory.class, nestedBuildFactory);
ListenerManager listenerManager = serviceRegistry.get(ListenerManager.class);
LoggingManagerInternal loggingManager = serviceRegistry.newInstance(LoggingManagerInternal.class);
loggingManager.setLevelInternal(startParameter.getLogLevel());
//this hooks up the ListenerManager and LoggingConfigurer so you can call Gradle.addListener() with a StandardOutputListener.
loggingManager.addStandardOutputListener(listenerManager.getBroadcaster(StandardOutputListener.class));
loggingManager.addStandardErrorListener(listenerManager.getBroadcaster(StandardOutputListener.class));
LoggerProvider loggerProvider = (parent == null) ? buildProgressLogger : LoggerProvider.NO_OP;
listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
if (parent == null) {
listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData));
}
if (startParameter.isBuildCacheEnabled()) {
listenerManager.addListener(serviceRegistry.get(TaskExecutionStatisticsEventAdapter.class));
listenerManager.addListener(new CacheStatisticsReporter(serviceRegistry.get(StyledTextOutputFactory.class)));
}
listenerManager.addListener(serviceRegistry.get(ProfileEventAdapter.class));
if (startParameter.isProfile()) {
listenerManager.addListener(new ReportGeneratingProfileListener(serviceRegistry.get(StyledTextOutputFactory.class)));
}
BuildScanRequest buildScanRequest = serviceRegistry.get(BuildScanRequest.class);
if (startParameter.isBuildScan()) {
if (!startParameter.getSystemPropertiesArgs().containsKey("scan")) {
startParameter.getSystemPropertiesArgs().put("scan", "true");
}
buildScanRequest.markRequested();
listenerManager.addListener(new BuildScanRequestListener());
}
if (startParameter.isNoBuildScan()) {
if (!startParameter.getSystemPropertiesArgs().containsKey("scan")) {
startParameter.getSystemPropertiesArgs().put("scan", "false");
}
buildScanRequest.markDisabled();
}
ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
listenerManager.addListener(usageLocationReporter);
BuildOutputCleanupListener buildOutputCleanupListener = serviceRegistry.get(BuildOutputCleanupListener.class);
listenerManager.addListener(buildOutputCleanupListener);
ShowStacktrace showStacktrace = startParameter.getShowStacktrace();
switch(showStacktrace) {
case ALWAYS:
case ALWAYS_FULL:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(true);
break;
default:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(false);
}
DeprecationLogger.useLocationReporter(usageLocationReporter);
SettingsLoaderFactory settingsLoaderFactory = serviceRegistry.get(SettingsLoaderFactory.class);
SettingsLoader settingsLoader = parent != null ? settingsLoaderFactory.forNestedBuild() : settingsLoaderFactory.forTopLevelBuild();
GradleInternal parentBuild = parent == null ? null : parent.getGradle();
GradleInternal gradle = serviceRegistry.get(Instantiator.class).newInstance(DefaultGradle.class, parentBuild, startParameter, serviceRegistry.get(ServiceRegistryFactory.class));
DefaultGradleLauncher gradleLauncher = new DefaultGradleLauncher(gradle, serviceRegistry.get(InitScriptHandler.class), settingsLoader, serviceRegistry.get(BuildConfigurer.class), serviceRegistry.get(ExceptionAnalyser.class), loggingManager, gradle.getBuildListenerBroadcaster(), listenerManager.getBroadcaster(ModelConfigurationListener.class), listenerManager.getBroadcaster(BuildCompletionListener.class), serviceRegistry.get(BuildOperationExecutor.class), gradle.getServices().get(BuildConfigurationActionExecuter.class), gradle.getServices().get(BuildExecuter.class), serviceRegistry, servicesToStop);
nestedBuildFactory.setParent(gradleLauncher);
return gradleLauncher;
}
use of org.gradle.api.logging.configuration.ShowStacktrace in project gradle by gradle.
the class LoggingCommandLineConverter method convert.
public LoggingConfiguration convert(ParsedCommandLine commandLine, LoggingConfiguration loggingConfiguration) throws CommandLineArgumentException {
for (Map.Entry<String, LogLevel> entry : logLevelMap.entrySet()) {
if (commandLine.hasOption(entry.getKey())) {
loggingConfiguration.setLogLevel(entry.getValue());
}
}
for (Map.Entry<String, ShowStacktrace> entry : showStacktraceMap.entrySet()) {
if (commandLine.hasOption(entry.getKey())) {
loggingConfiguration.setShowStacktrace(entry.getValue());
}
}
if (commandLine.hasOption(CONSOLE)) {
String value = commandLine.option(CONSOLE).getValue();
String consoleValue = StringUtils.capitalize(value.toLowerCase(Locale.ENGLISH));
try {
ConsoleOutput consoleOutput = ConsoleOutput.valueOf(consoleValue);
loggingConfiguration.setConsoleOutput(consoleOutput);
} catch (IllegalArgumentException e) {
throw new CommandLineArgumentException(String.format("Unrecognized value '%s' for %s.", value, CONSOLE));
}
}
return loggingConfiguration;
}
use of org.gradle.api.logging.configuration.ShowStacktrace in project gradle by gradle.
the class DefaultGradleLauncherFactory method doNewInstance.
private DefaultGradleLauncher doNewInstance(BuildDefinition buildDefinition, @Nullable GradleLauncher parent, BuildCancellationToken cancellationToken, BuildRequestMetaData requestMetaData, BuildEventConsumer buildEventConsumer, final BuildTreeScopeServices buildTreeScopeServices, List<?> servicesToStop) {
BuildScopeServices serviceRegistry = new BuildScopeServices(buildTreeScopeServices);
serviceRegistry.add(BuildDefinition.class, buildDefinition);
serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
serviceRegistry.add(BuildEventConsumer.class, buildEventConsumer);
serviceRegistry.add(BuildCancellationToken.class, cancellationToken);
serviceRegistry.add(BuildIdentity.class, new DefaultBuildIdentity(buildDefinition, parent == null));
NestedBuildFactoryImpl nestedBuildFactory = new NestedBuildFactoryImpl(buildTreeScopeServices);
serviceRegistry.add(NestedBuildFactory.class, nestedBuildFactory);
StartParameter startParameter = buildDefinition.getStartParameter();
ListenerManager listenerManager = serviceRegistry.get(ListenerManager.class);
LoggerProvider loggerProvider = (parent == null) ? buildProgressLogger : LoggerProvider.NO_OP;
listenerManager.useLogger(new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class), loggerProvider));
if (parent == null) {
BuildStartedTime buildStartedTime = serviceRegistry.get(BuildStartedTime.class);
Clock clock = serviceRegistry.get(Clock.class);
listenerManager.useLogger(new BuildLogger(Logging.getLogger(BuildLogger.class), serviceRegistry.get(StyledTextOutputFactory.class), startParameter, requestMetaData, buildStartedTime, clock));
}
listenerManager.addListener(serviceRegistry.get(TaskExecutionStatisticsEventAdapter.class));
listenerManager.addListener(new TaskExecutionStatisticsReporter(serviceRegistry.get(StyledTextOutputFactory.class)));
listenerManager.addListener(serviceRegistry.get(ProfileEventAdapter.class));
if (startParameter.isProfile()) {
listenerManager.addListener(new ReportGeneratingProfileListener(serviceRegistry.get(StyledTextOutputFactory.class)));
}
ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
listenerManager.addListener(usageLocationReporter);
ShowStacktrace showStacktrace = startParameter.getShowStacktrace();
switch(showStacktrace) {
case ALWAYS:
case ALWAYS_FULL:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(true);
break;
default:
LoggingDeprecatedFeatureHandler.setTraceLoggingEnabled(false);
}
DeprecationLogger.init(usageLocationReporter, startParameter.getWarningMode());
SettingsLoaderFactory settingsLoaderFactory = serviceRegistry.get(SettingsLoaderFactory.class);
SettingsLoader settingsLoader = parent != null ? settingsLoaderFactory.forNestedBuild() : settingsLoaderFactory.forTopLevelBuild();
GradleInternal parentBuild = parent == null ? null : parent.getGradle();
GradleInternal gradle = serviceRegistry.get(Instantiator.class).newInstance(DefaultGradle.class, parentBuild, startParameter, serviceRegistry.get(ServiceRegistryFactory.class));
DefaultGradleLauncher gradleLauncher = new DefaultGradleLauncher(gradle, serviceRegistry.get(InitScriptHandler.class), settingsLoader, serviceRegistry.get(BuildLoader.class), serviceRegistry.get(BuildConfigurer.class), serviceRegistry.get(ExceptionAnalyser.class), gradle.getBuildListenerBroadcaster(), listenerManager.getBroadcaster(ModelConfigurationListener.class), listenerManager.getBroadcaster(BuildCompletionListener.class), serviceRegistry.get(BuildOperationExecutor.class), gradle.getServices().get(BuildConfigurationActionExecuter.class), gradle.getServices().get(BuildExecuter.class), serviceRegistry, servicesToStop);
nestedBuildFactory.setParent(gradleLauncher);
return gradleLauncher;
}
Aggregations