use of com.facebook.buck.io.WatchmanDiagnosticEventListener in project buck by facebook.
the class Main method addEventListeners.
@SuppressWarnings("PMD.PrematureDeclaration")
private ImmutableList<BuckEventListener> addEventListeners(BuckEventBus buckEventBus, ProjectFilesystem projectFilesystem, InvocationInfo invocationInfo, BuckConfig buckConfig, Optional<WebServer> webServer, Clock clock, AbstractConsoleEventBusListener consoleEventBusListener, Supplier<BuckEventListener> missingSymbolsListenerSupplier, CounterRegistry counterRegistry, Iterable<BuckEventListener> commandSpecificEventListeners) {
ImmutableList.Builder<BuckEventListener> eventListenersBuilder = ImmutableList.<BuckEventListener>builder().add(new JavaUtilsLoggingBuildListener()).add(consoleEventBusListener).add(new LoggingBuildListener());
if (buckConfig.isChromeTraceCreationEnabled()) {
try {
eventListenersBuilder.add(new ChromeTraceBuildListener(projectFilesystem, invocationInfo, clock, objectMapper, buckConfig.getMaxTraces(), buckConfig.getCompressTraces()));
} catch (IOException e) {
LOG.error("Unable to create ChromeTrace listener!");
}
} else {
LOG.warn("::: ChromeTrace listener disabled");
}
if (webServer.isPresent()) {
eventListenersBuilder.add(webServer.get().createListener());
}
loadListenersFromBuckConfig(eventListenersBuilder, projectFilesystem, buckConfig);
if (buckConfig.isRuleKeyLoggerEnabled()) {
eventListenersBuilder.add(new RuleKeyLoggerListener(projectFilesystem, invocationInfo, MostExecutors.newSingleThreadExecutor(new CommandThreadFactory(getClass().getName()))));
}
if (buckConfig.isMachineReadableLoggerEnabled()) {
try {
eventListenersBuilder.add(new MachineReadableLoggerListener(invocationInfo, projectFilesystem, MostExecutors.newSingleThreadExecutor(new CommandThreadFactory(getClass().getName()))));
} catch (FileNotFoundException e) {
LOG.warn("Unable to open stream for machine readable log file.");
}
}
JavaBuckConfig javaBuckConfig = buckConfig.getView(JavaBuckConfig.class);
if (!javaBuckConfig.getSkipCheckingMissingDeps()) {
eventListenersBuilder.add(missingSymbolsListenerSupplier.get());
}
eventListenersBuilder.add(new LoadBalancerEventsListener(counterRegistry));
eventListenersBuilder.add(new CacheRateStatsListener(buckEventBus));
eventListenersBuilder.add(new WatchmanDiagnosticEventListener(buckEventBus));
eventListenersBuilder.addAll(commandSpecificEventListeners);
ImmutableList<BuckEventListener> eventListeners = eventListenersBuilder.build();
eventListeners.forEach(buckEventBus::register);
return eventListeners;
}
use of com.facebook.buck.io.WatchmanDiagnosticEventListener in project buck by facebook.
the class WatchmanWatcherTest method whenWatchmanProducesAWarningThenWarningAddedToCache.
@Test
public void whenWatchmanProducesAWarningThenWarningAddedToCache() throws IOException, InterruptedException {
String message = "I'm a warning!";
ImmutableMap<String, Object> watchmanOutput = ImmutableMap.of("files", ImmutableList.of(), "warning", message);
EventBus eventBus = new EventBus("watchman test");
WatchmanWatcher watcher = createWatcher(eventBus, watchmanOutput);
Set<WatchmanDiagnostic> diagnostics = new HashSet<>();
BuckEventBus buckEventBus = BuckEventBusFactory.newInstance(new FakeClock(0));
buckEventBus.register(new WatchmanDiagnosticEventListener(buckEventBus, diagnostics));
watcher.postEvents(buckEventBus, WatchmanWatcher.FreshInstanceAction.NONE);
assertThat(diagnostics, hasItem(WatchmanDiagnostic.of(WatchmanDiagnostic.Level.WARNING, message)));
}
Aggregations