Search in sources :

Example 1 with GuiLoggerAppender

use of com.luastar.swift.tools.view.GuiLoggerAppender in project swift by luastar.

the class MainController method initConsoleTextArea.

/**
 * 初始化控制台
 */
private void initConsoleTextArea() {
    // 不可编辑
    consoleTextArea.setEditable(false);
    // 右键清除按钮
    MenuItem clear = new MenuItem("清除");
    clear.setOnAction(event -> consoleTextArea.clear());
    ContextMenu contextMenu = new ContextMenu();
    contextMenu.getItems().add(clear);
    consoleTextArea.setContextMenu(contextMenu);
    // 设置日志属性
    Logger rootLogger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Appender<ILoggingEvent> appender = rootLogger.getAppender("gui");
    if (appender != null && (appender instanceof GuiLoggerAppender)) {
        ((GuiLoggerAppender) appender).setConsoleTextArea(consoleTextArea);
    }
}
Also used : GuiLoggerAppender(com.luastar.swift.tools.view.GuiLoggerAppender) MenuItem(javafx.scene.control.MenuItem) ContextMenu(javafx.scene.control.ContextMenu) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Aggregations

Logger (ch.qos.logback.classic.Logger)1 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 GuiLoggerAppender (com.luastar.swift.tools.view.GuiLoggerAppender)1 ContextMenu (javafx.scene.control.ContextMenu)1 MenuItem (javafx.scene.control.MenuItem)1