mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-08 11:34:07 +08:00
Fixed: Stdin not being logged for background execution commands
This commit is contained in:
@@ -240,7 +240,7 @@ public class ExecutionCommand {
|
||||
@Override
|
||||
public String toString() {
|
||||
if (!hasExecuted())
|
||||
return getExecutionInputLogString(this, true);
|
||||
return getExecutionInputLogString(this, true, true);
|
||||
else {
|
||||
return getExecutionOutputLogString(this, true, true);
|
||||
}
|
||||
@@ -251,9 +251,10 @@ public class ExecutionCommand {
|
||||
*
|
||||
* @param executionCommand The {@link ExecutionCommand} to convert.
|
||||
* @param ignoreNull Set to {@code true} if non-critical {@code null} values are to be ignored.
|
||||
* @param logStdin Set to {@code true} if {@link #stdin} should be logged.
|
||||
* @return Returns the log friendly {@link String}.
|
||||
*/
|
||||
public static String getExecutionInputLogString(final ExecutionCommand executionCommand, boolean ignoreNull) {
|
||||
public static String getExecutionInputLogString(final ExecutionCommand executionCommand, boolean ignoreNull, boolean logStdin) {
|
||||
if (executionCommand == null) return "null";
|
||||
|
||||
StringBuilder logString = new StringBuilder();
|
||||
@@ -270,8 +271,13 @@ public class ExecutionCommand {
|
||||
logString.append("\n").append(executionCommand.getInBackgroundLogString());
|
||||
logString.append("\n").append(executionCommand.getIsFailsafeLogString());
|
||||
|
||||
if (executionCommand.inBackground && (!ignoreNull || executionCommand.backgroundCustomLogLevel != null))
|
||||
logString.append("\n").append(executionCommand.getBackgroundCustomLogLevelLogString());
|
||||
if (executionCommand.inBackground) {
|
||||
if (logStdin && (!ignoreNull || !DataUtils.isNullOrEmpty(executionCommand.stdin)))
|
||||
logString.append("\n").append(executionCommand.getStdinLogString());
|
||||
|
||||
if (!ignoreNull || executionCommand.backgroundCustomLogLevel != null)
|
||||
logString.append("\n").append(executionCommand.getBackgroundCustomLogLevelLogString());
|
||||
}
|
||||
|
||||
if (!ignoreNull || executionCommand.sessionAction != null)
|
||||
logString.append("\n").append(executionCommand.getSessionActionLogString());
|
||||
@@ -321,7 +327,7 @@ public class ExecutionCommand {
|
||||
|
||||
StringBuilder logString = new StringBuilder();
|
||||
|
||||
logString.append(getExecutionInputLogString(executionCommand, false));
|
||||
logString.append(getExecutionInputLogString(executionCommand, false, true));
|
||||
logString.append(getExecutionOutputLogString(executionCommand, false, true));
|
||||
|
||||
logString.append("\n").append(executionCommand.getCommandDescriptionLogString());
|
||||
@@ -356,8 +362,12 @@ public class ExecutionCommand {
|
||||
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("inBackground", executionCommand.inBackground, "-"));
|
||||
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("isFailsafe", executionCommand.isFailsafe, "-"));
|
||||
|
||||
if (executionCommand.inBackground && executionCommand.backgroundCustomLogLevel != null)
|
||||
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Background Custom Log Level", executionCommand.backgroundCustomLogLevel, "-"));
|
||||
if (executionCommand.inBackground) {
|
||||
if (!DataUtils.isNullOrEmpty(executionCommand.stdin))
|
||||
markdownString.append("\n").append(MarkdownUtils.getMultiLineMarkdownStringEntry("Stdin", executionCommand.stdin, "-"));
|
||||
if (executionCommand.backgroundCustomLogLevel != null)
|
||||
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Background Custom Log Level", executionCommand.backgroundCustomLogLevel, "-"));
|
||||
}
|
||||
|
||||
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Session Action", executionCommand.sessionAction, "-"));
|
||||
|
||||
@@ -431,6 +441,13 @@ public class ExecutionCommand {
|
||||
return "isFailsafe: `" + isFailsafe + "`";
|
||||
}
|
||||
|
||||
public String getStdinLogString() {
|
||||
if (DataUtils.isNullOrEmpty(stdin))
|
||||
return "Stdin: -";
|
||||
else
|
||||
return Logger.getMultiLineLogStringEntry("Stdin", stdin, "-");
|
||||
}
|
||||
|
||||
public String getBackgroundCustomLogLevelLogString() {
|
||||
return "Background Custom Log Level: `" + backgroundCustomLogLevel + "`";
|
||||
}
|
||||
|
Reference in New Issue
Block a user