use of com.canoo.platform.logging.spi.LogMessage in project dolphin-platform by canoo.
the class ViewSample method createMessage.
private LogMessage createMessage(final Level level, final String message) {
final LogMessage logMessage = new LogMessage();
logMessage.setTimestamp(ZonedDateTime.now());
logMessage.setLevel(level);
logMessage.setMessage(message);
return logMessage;
}
use of com.canoo.platform.logging.spi.LogMessage in project dolphin-platform by canoo.
the class LogClientUtil method createObservableListFromLocalCache.
public static BoundLogList<LogMessage> createObservableListFromLocalCache() {
final ObservableList<LogMessage> list = FXCollections.observableArrayList(DolphinLoggerFactory.getLogCache());
final Subscription subscription = DolphinLoggerFactory.addListener(l -> {
final List<LogMessage> currentCache = Collections.unmodifiableList(DolphinLoggerFactory.getLogCache());
Platform.runLater(() -> {
final List<LogMessage> toRemove = list.stream().filter(e -> !currentCache.contains(l)).collect(Collectors.toList());
list.removeAll(toRemove);
final List<LogMessage> toAdd = currentCache.stream().filter(e -> !list.contains(e)).collect(Collectors.toList());
list.addAll(toAdd);
});
});
return new BoundLogList(subscription, list);
}
use of com.canoo.platform.logging.spi.LogMessage in project dolphin-platform by canoo.
the class LogListViewController method convertBean.
private LogMessage convertBean(final LogEntryBean bean) {
Assert.requireNonNull(bean, "bean");
final LogMessage message = new LogMessage();
message.setMessage(bean.getMessage());
message.setLevel(bean.getLogLevel());
message.setTimestamp(bean.getLogTimestamp());
return message;
}
use of com.canoo.platform.logging.spi.LogMessage in project dolphin-platform by canoo.
the class ViewSample method createMessage.
private LogMessage createMessage(final Level level, final String message, final Throwable throwable) {
final LogMessage logMessage = createMessage(level, message);
logMessage.setThrowable(throwable);
return logMessage;
}
use of com.canoo.platform.logging.spi.LogMessage in project dolphin-platform by canoo.
the class ViewSample method start.
@Override
public void start(final Stage primaryStage) throws Exception {
final ListView<LogMessage> listView = new ListView<>();
listView.setCellFactory(v -> new LogListCell());
listView.setItems(LogClientUtil.createObservableListFromLocalCache());
Executors.newSingleThreadExecutor().execute(() -> {
while (true) {
try {
Thread.sleep(2_000);
} catch (InterruptedException e) {
}
LOG.info(MarkerFactory.getMarker("MyMarker"), "System " + UUID.randomUUID() + " starting");
LOG.info("Found 3 modules");
LOG.debug("Starting module 'Base'");
if (Math.random() > 0.5) {
LOG.trace("Module 'Base' started in 45 ms");
} else {
LOG.trace("Module 'Base' is using default configuration");
LOG.trace("Module 'Base' started in 67 ms");
}
LOG.debug("Starting module 'Platform'");
if (Math.random() > 0.5) {
LOG.trace("Module 'Platform' started in 35 ms");
} else {
LOG.warn("Module 'Platform' is using default configuration! Please configure it!");
LOG.trace("Module 'Platform' started in 67 ms");
}
LOG.debug("Starting module 'Security'");
if (Math.random() > 0.5) {
LOG.trace("Module 'Security' started in 35 ms");
} else {
LOG.error("Module 'Security' can not be started!", new RuntimeException("Error in param foo"));
}
}
});
Executors.newSingleThreadExecutor().execute(() -> {
while (true) {
try {
Thread.sleep(1_500);
} catch (InterruptedException e) {
}
LOG.trace("Will ping server");
LOG.debug("Server ping returned in 42 ms");
}
});
final LogFilterView filterView = new LogFilterView();
final VBox main = new VBox(filterView, listView);
main.setFillWidth(true);
VBox.setVgrow(filterView, Priority.NEVER);
VBox.setVgrow(listView, Priority.ALWAYS);
primaryStage.setScene(new Scene(main));
primaryStage.show();
}
Aggregations