Skip to content

Commit 7f39331

Browse files
authored
Merge pull request #45 from royalhuang/issue_39
feat: 日志统一输出流 #39 修复日志错误流问题
2 parents d978e38 + f05f6f4 commit 7f39331

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/main/java/org/slf4j/impl/SimpleLogger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class SimpleLogger extends MarkerIgnoringBase {
142142
private static boolean SHOW_THREAD_NAME = false;
143143
private static boolean SHOW_LOG_NAME = false;
144144
private static boolean SHOW_SHORT_LOG_NAME = false;
145-
private static String LOG_FILE = "System.err";
145+
private static String LOG_FILE = "System.out";
146146
private static PrintStream TARGET_STREAM = null;
147147
private static boolean LEVEL_IN_BRACKETS = false;
148148
private static String WARN_LEVEL_STRING = "WARN";

src/main/kotlin/com/tencent/bk/devops/plugin/script/CommandLineUtils.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,21 @@ object CommandLineUtils {
3333
result.append(tmpLine).append("\n")
3434
}
3535
}
36-
executor.streamHandler = PumpStreamHandler(outputStream)
36+
37+
val errorStream = object : LogOutputStream() {
38+
override fun processLine(line: String?, level: Int) {
39+
if (line == null) {
40+
return
41+
}
42+
43+
val tmpLine = SensitiveLineParser.onParseLine(prefix + line)
44+
if (print2Logger) {
45+
logger.error(tmpLine)
46+
}
47+
result.append(tmpLine).append("\n")
48+
}
49+
}
50+
executor.streamHandler = PumpStreamHandler(outputStream, errorStream)
3751

3852
try {
3953
val exitCode = executor.execute(cmdLine)

0 commit comments

Comments
 (0)