Skip to content

Commit 017fc37

Browse files
committed
[+] 添加OS_DEPENDENT颜色支持级别
1 parent b01db70 commit 017fc37

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/cc/moecraft/logger/environments/ColorSupportLevel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ public enum ColorSupportLevel
1313
DEFAULT, // 默认支持
1414
PRESET_ONLY, // 只输出预设颜色, 移除RGB
1515
PASSTHROUGH, // Jansi的Passthrough
16-
FORCED // 不传入Jansi
16+
FORCED, // 不传入Jansi
17+
18+
OS_DEPENDENT // 如果是Windows, 就改为PRESET_ONLY, 如果是Linux或者OSX, 就改为DEFAULT
1719
}

src/main/java/cc/moecraft/logger/environments/ConsoleColoredEnv.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import org.fusesource.jansi.AnsiConsole;
44

5-
import static cc.moecraft.logger.environments.ColorSupportLevel.FORCED;
6-
import static cc.moecraft.logger.environments.ColorSupportLevel.PASSTHROUGH;
7-
import static cc.moecraft.logger.environments.ColorSupportLevel.PRESET_ONLY;
5+
import static cc.moecraft.logger.environments.ColorSupportLevel.*;
86

97
/**
108
* 此类由 Hykilpikonna 在 2018/07/03 创建!
@@ -20,6 +18,10 @@ public class ConsoleColoredEnv extends LogEnvironment
2018

2119
public ConsoleColoredEnv(ColorSupportLevel colorSupportLevel)
2220
{
21+
if (colorSupportLevel == OS_DEPENDENT)
22+
if (System.getProperty("os.name").toLowerCase().contains("win")) colorSupportLevel = PRESET_ONLY;
23+
else colorSupportLevel = DEFAULT;
24+
2325
this.colorSupportLevel = colorSupportLevel;
2426
if (colorSupportLevel != FORCED && colorSupportLevel == PASSTHROUGH) System.getProperties().setProperty("jansi.passthrough", "true");
2527
}

0 commit comments

Comments
 (0)