Search in sources :

Example 1 with LogMessage

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;
}
Also used : LogMessage(com.canoo.platform.logging.spi.LogMessage)

Example 2 with 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);
}
Also used : Platform(javafx.application.Platform) List(java.util.List) Subscription(com.canoo.platform.core.functional.Subscription) DolphinLoggerFactory(com.canoo.impl.dp.logging.DolphinLoggerFactory) FXCollections(javafx.collections.FXCollections) ObservableList(javafx.collections.ObservableList) LogMessage(com.canoo.platform.logging.spi.LogMessage) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) LogMessage(com.canoo.platform.logging.spi.LogMessage) Subscription(com.canoo.platform.core.functional.Subscription)

Example 3 with LogMessage

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;
}
Also used : LogMessage(com.canoo.platform.logging.spi.LogMessage)

Example 4 with LogMessage

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;
}
Also used : LogMessage(com.canoo.platform.logging.spi.LogMessage)

Example 5 with 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();
}
Also used : LogFilterView(com.canoo.platform.logger.client.widgets.LogFilterView) ListView(javafx.scene.control.ListView) LogMessage(com.canoo.platform.logging.spi.LogMessage) LogListCell(com.canoo.platform.logger.client.widgets.LogListCell) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox)

Aggregations

LogMessage (com.canoo.platform.logging.spi.LogMessage)9 Optional (java.util.Optional)3 Level (org.slf4j.event.Level)3 DolphinLoggerBridge (com.canoo.platform.logging.spi.DolphinLoggerBridge)2 FontAwesomeIcon (de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon)2 FontAwesomeIconView (de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Collections (java.util.Collections)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 Insets (javafx.geometry.Insets)2 Label (javafx.scene.control.Label)2 HBox (javafx.scene.layout.HBox)2 VBox (javafx.scene.layout.VBox)2 Assert (com.canoo.dp.impl.platform.core.Assert)1 AnsiOut (com.canoo.dp.impl.platform.core.ansi.AnsiOut)1 DolphinLoggerFactory (com.canoo.impl.dp.logging.DolphinLoggerFactory)1 Subscription (com.canoo.platform.core.functional.Subscription)1 LogFilterView (com.canoo.platform.logger.client.widgets.LogFilterView)1 LogListCell (com.canoo.platform.logger.client.widgets.LogListCell)1 LoggerSearchRequest (com.canoo.platform.logger.model.LoggerSearchRequest)1