use of org.gradle.internal.logging.LoggingManagerInternal in project gradle by gradle.
the class ProviderConnection method configure.
public void configure(ProviderConnectionParameters parameters) {
LogLevel providerLogLevel = parameters.getVerboseLogging() ? LogLevel.DEBUG : LogLevel.INFO;
LOGGER.debug("Configuring logging to level: {}", providerLogLevel);
LoggingManagerInternal loggingManager = loggingServices.newInstance(LoggingManagerInternal.class);
loggingManager.setLevelInternal(providerLogLevel);
loggingManager.start();
}
use of org.gradle.internal.logging.LoggingManagerInternal in project gradle by gradle.
the class AbstractMavenPublisher method execute.
private void execute(MavenPublishAction publishAction) {
LoggingManagerInternal loggingManager = loggingManagerFactory.create();
loggingManager.captureStandardOutput(LogLevel.INFO).start();
try {
publishAction.publish();
} finally {
loggingManager.stop();
}
}
use of org.gradle.internal.logging.LoggingManagerInternal in project gradle by gradle.
the class SystemApplicationClassLoaderWorker method call.
public Void call() throws Exception {
if (System.getProperty("org.gradle.worker.test.stuck") != null) {
// Simulate a stuck worker. There's probably a way to inject this failure...
Thread.sleep(30000);
return null;
}
Decoder decoder = new InputStreamBackedDecoder(configInputStream);
// Read logging config and setup logging
int logLevel = decoder.readSmallInt();
LoggingManagerInternal loggingManager = createLoggingManager();
loggingManager.setLevelInternal(LogLevel.values()[logLevel]).start();
// Read whether process info should be published
boolean shouldPublishJvmMemoryInfo = decoder.readBoolean();
// Read path to Gradle user home
String gradleUserHomeDirPath = decoder.readString();
File gradleUserHomeDir = new File(gradleUserHomeDirPath);
// Read server address and start connecting
MultiChoiceAddress serverAddress = new MultiChoiceAddressSerializer().read(decoder);
MessagingServices messagingServices = new MessagingServices();
final WorkerServices workerServices = new WorkerServices(messagingServices, gradleUserHomeDir);
ObjectConnection connection = null;
WorkerLogEventListener workerLogEventListener = null;
try {
// Read serialized worker
byte[] serializedWorker = decoder.readBinary();
// Deserialize the worker action
Action<WorkerContext> action;
try {
ObjectInputStream instr = new ClassLoaderObjectInputStream(new ByteArrayInputStream(serializedWorker), getClass().getClassLoader());
action = (Action<WorkerContext>) instr.readObject();
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
connection = messagingServices.get(MessagingClient.class).getConnection(serverAddress);
workerLogEventListener = configureLogging(loggingManager, connection);
if (shouldPublishJvmMemoryInfo) {
configureWorkerJvmMemoryInfoEvents(workerServices, connection);
}
final ObjectConnection serverConnection = connection;
action.execute(new WorkerContext() {
public ClassLoader getApplicationClassLoader() {
return ClassLoader.getSystemClassLoader();
}
@Override
public ObjectConnection getServerConnection() {
return serverConnection;
}
@Override
public ServiceRegistry getServiceRegistry() {
return workerServices;
}
});
} finally {
if (workerLogEventListener != null) {
loggingManager.removeOutputEventListener(workerLogEventListener);
}
if (connection != null) {
connection.stop();
}
messagingServices.close();
loggingManager.stop();
}
return null;
}
use of org.gradle.internal.logging.LoggingManagerInternal in project gradle by gradle.
the class ProviderConnection method createExecuter.
private BuildActionExecuter<ProviderOperationParameters> createExecuter(ProviderOperationParameters operationParameters, Parameters params) {
LoggingManagerInternal loggingManager;
BuildActionExecuter<BuildActionParameters> executer;
if (Boolean.TRUE.equals(operationParameters.isEmbedded())) {
loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
loggingManager.captureSystemSources();
executer = embeddedExecutor;
} else {
LoggingServiceRegistry loggingServices = LoggingServiceRegistry.newNestedLogging();
loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
InputStream standardInput = operationParameters.getStandardInput();
ServiceRegistry clientServices = daemonClientFactory.createBuildClientServices(loggingServices.get(OutputEventListener.class), params.daemonParams, standardInput == null ? SafeStreams.emptyInput() : standardInput);
executer = clientServices.get(DaemonClient.class);
}
return new LoggingBridgingBuildActionExecuter(new DaemonBuildActionExecuter(executer, params.daemonParams), loggingManager);
}
use of org.gradle.internal.logging.LoggingManagerInternal in project gradle by gradle.
the class LoggingServiceRegistry method newCommandLineProcessLogging.
/**
* Creates a set of logging services which are suitable to use globally in a process. In particular:
*
* <ul>
* <li>Replaces System.out and System.err with implementations that route output through the logging system as per {@link LoggingManagerInternal#captureSystemSources()}.</li>
* <li>Configures slf4j, log4j and java util logging to route log messages through the logging system.</li>
* <li>Routes logging output to the original System.out and System.err as per {@link LoggingManagerInternal#attachSystemOutAndErr()}.</li>
* <li>Sets log level to {@link org.gradle.api.logging.LogLevel#LIFECYCLE}.</li>
* </ul>
*
* <p>Does nothing until started.</p>
*
* <p>Allows dynamic and colored output to be written to the console. Use {@link LoggingManagerInternal#attachProcessConsole(org.gradle.api.logging.configuration.ConsoleOutput)} to enable this.</p>
*/
public static LoggingServiceRegistry newCommandLineProcessLogging() {
CommandLineLogging loggingServices = new CommandLineLogging();
LoggingManagerInternal rootLoggingManager = loggingServices.get(DefaultLoggingManagerFactory.class).getRoot();
rootLoggingManager.captureSystemSources();
rootLoggingManager.attachSystemOutAndErr();
return loggingServices;
}
Aggregations