-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.添加log控制台功能;2、添加注释;3、更新说明文件0.1.5版本。
- Loading branch information
Showing
37 changed files
with
507 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/xwintop/xJavaFxTool/common/logback/ConsoleLogAppender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.xwintop.xJavaFxTool.common.logback; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.OutputStreamAppender; | ||
import javafx.scene.control.TextArea; | ||
import lombok.Data; | ||
|
||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* @ClassName: ConsoleLogAppender | ||
* @Description: 日志打印控制台 | ||
* @author: xufeng | ||
* @date: 2019/4/25 0025 23:18 | ||
*/ | ||
|
||
@Data | ||
public class ConsoleLogAppender extends OutputStreamAppender<ILoggingEvent> { | ||
public final static List<TextArea> textAreaList = new ArrayList<>(); | ||
|
||
@Override | ||
public void start() { | ||
OutputStream targetStream = new OutputStream() { | ||
@Override | ||
public void write(int b) throws IOException { | ||
for (TextArea textArea : textAreaList) { | ||
textArea.appendText(b + "\n"); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(byte[] b) throws IOException { | ||
for (TextArea textArea : textAreaList) { | ||
textArea.appendText(new String(b) + "\n"); | ||
} | ||
} | ||
}; | ||
setOutputStream(targetStream); | ||
super.start(); | ||
} | ||
} |
Oops, something went wrong.