Skip to content

Commit 60f37bd

Browse files
Changed!: StreamGobbler needs to be passed log level parameter
When `Logger.CURRENT_LOG_LEVEL` set by user is `Logger.LOG_VERBOSE`, then background (not foreground sessions) command output was being logged to logcat, however, if command outputted too much data to logcat, then logcat clients like in Android Studio would crash. Also if a logcat dump is being taken inside termux, then duplicate lines would occur, first one due to of original entry, and second one due to StreamGobbler logging output at verbose level for logcat command. This would be a concern for plugins as well like `RUN_COMMAND` intent or Termux:Tasker, etc if they ran commands with lot of data and user had set log level to verbose. For plugins, TermuxService now supports `com.termux.execute.background_custom_log_level` `String` extra for custom log level. Termux:Tasker, etc will have to be updated with support. For `RUN_COMMAND` intent, the `com.termux.RUN_COMMAND_BACKGROUND_CUSTOM_LOG_LEVEL` `String` extra is now provided to set custom log level for only the command output. Check `TermuxConstants`. So one can pass a custom log level that is `>=` to the log level set it termux settings where (OFF=0, NORMAL=1, DEBUG=2, VERBOSE=3). If you pass `0`, it will completely disable logging. If you pass `1`, logging will only be enabled if log level in termux settings is `NORMAL` or higher. If custom log level is not passed, then old behaviour will remain and log level in termux settings must be `VERBOSE` or higher for logging to be enabled. Note that the log entries will still be logged with priority `Log.VERBOSE` regardless of log level, i.e `logcat` will have `V/`. The entries logcat component has now changed from `StreamGobbler` to `TermuxCommand`. For output at `stdout`, the entry format is `[<pid>-stdout] ...` and for the output at `stderr`, the entry format is `[<pid>-stderr] ...`. The `<pid>` will be process id as an integer that was started by termux. For example: `V/TermuxCommand: [66666-stdout] ...`. While doing this I realize that instead of using `am` command to send messages back to tasker, you can use tasker `Logcat Entry` profile event to listen to messages from termux at both `stdout` and `stderr`. This might be faster than `am` command intent systems or at least possibly more convenient in some use cases. So setup a profile with the `Component` value set to `TermuxCommand` and `Filter` value set to `-E 'TermuxCommand: \[[0-9]+-((stdout)|(stderr))\] message_tag: .*'` and enable the `Grep Filter` toggle so that entry matching is done in native code. Check https://github.com/joaomgcd/TaskerDocumentation/blob/master/en/help/logcat%20info.md for details. Also enable `Enforce Task Order` in profile settings and set collision handling to `Run Both Together` so that if two or more entries are sent quickly, entry task is run for all. Tasker currently (v5.13.16) is not maintaining order of entry tasks despite the setting. Then you can send an intent from tasker via `Run Shell` action with `root` (since `am` command won't work without it on android >=8) or normally in termux from a script, you should be able to receive the entries as `@lc_text` in entry task of tasker `Logcat Entry` profile. The following just passes two `echo` commands to `bash` as a script via `stdin`. If you don't have root, then you can call a wrapper script with `TermuxCommand` function in `Tasker Function` action that sends another `RUN_COMMAND` intent with termux provide `am` command which will work without root. ``` am startservice --user 0 -n com.termux/com.termux.app.RunCommandService -a com.termux.RUN_COMMAND --es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/bash' --es com.termux.RUN_COMMAND_STDIN 'echo "message_tag: Sending message from tasker to termux"' --ez com.termux.RUN_COMMAND_BACKGROUND true --es com.termux.RUN_COMMAND_BACKGROUND_CUSTOM_LOG_LEVEL '1' ```
1 parent fabcc4f commit 60f37bd

File tree

10 files changed

+115
-22
lines changed

10 files changed

+115
-22
lines changed

app/src/main/java/com/termux/app/RunCommandService.java

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
101101
executionCommand.stdin = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_STDIN, null);
102102
executionCommand.workingDirectory = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_WORKDIR, null);
103103
executionCommand.inBackground = intent.getBooleanExtra(RUN_COMMAND_SERVICE.EXTRA_BACKGROUND, false);
104+
executionCommand.backgroundCustomLogLevel = IntentUtils.getIntegerExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL, null);
104105
executionCommand.sessionAction = intent.getStringExtra(RUN_COMMAND_SERVICE.EXTRA_SESSION_ACTION);
105106
executionCommand.commandLabel = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_COMMAND_LABEL, "RUN_COMMAND Execution Intent Command");
106107
executionCommand.commandDescription = IntentUtils.getStringExtraIfSet(intent, RUN_COMMAND_SERVICE.EXTRA_COMMAND_DESCRIPTION, null);
@@ -197,6 +198,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
197198
execIntent.putExtra(TERMUX_SERVICE.EXTRA_STDIN, executionCommand.stdin);
198199
if (executionCommand.workingDirectory != null && !executionCommand.workingDirectory.isEmpty()) execIntent.putExtra(TERMUX_SERVICE.EXTRA_WORKDIR, executionCommand.workingDirectory);
199200
execIntent.putExtra(TERMUX_SERVICE.EXTRA_BACKGROUND, executionCommand.inBackground);
201+
execIntent.putExtra(TERMUX_SERVICE.EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL, DataUtils.getStringFromInteger(executionCommand.backgroundCustomLogLevel, null));
200202
execIntent.putExtra(TERMUX_SERVICE.EXTRA_SESSION_ACTION, executionCommand.sessionAction);
201203
execIntent.putExtra(TERMUX_SERVICE.EXTRA_COMMAND_LABEL, executionCommand.commandLabel);
202204
execIntent.putExtra(TERMUX_SERVICE.EXTRA_COMMAND_DESCRIPTION, executionCommand.commandDescription);

app/src/main/java/com/termux/app/TermuxService.java

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ private void actionServiceExecute(Intent intent) {
364364
executionCommand.arguments = IntentUtils.getStringArrayExtraIfSet(intent, TERMUX_SERVICE.EXTRA_ARGUMENTS, null);
365365
if (executionCommand.inBackground)
366366
executionCommand.stdin = IntentUtils.getStringExtraIfSet(intent, TERMUX_SERVICE.EXTRA_STDIN, null);
367+
executionCommand.backgroundCustomLogLevel = IntentUtils.getIntegerExtraIfSet(intent, TERMUX_SERVICE.EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL, null);
367368
}
368369

369370
executionCommand.workingDirectory = IntentUtils.getStringExtraIfSet(intent, TERMUX_SERVICE.EXTRA_WORKDIR, null);

termux-shared/src/main/java/com/termux/shared/data/DataUtils.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
import androidx.annotation.Nullable;
66

7-
import java.util.LinkedHashSet;
8-
import java.util.regex.Matcher;
9-
import java.util.regex.Pattern;
10-
117
public class DataUtils {
128

139
public static final int TRANSACTION_SIZE_LIMIT_IN_BYTES = 100 * 1024; // 100KB
@@ -97,6 +93,17 @@ public static int getIntFromString(String value, int def) {
9793
}
9894
}
9995

96+
/**
97+
* Get the {@code String} from an {@link Integer}.
98+
*
99+
* @param value The {@link Integer} value.
100+
* @param def The default {@link String} value.
101+
* @return Returns {@code value} if it is not {@code null}, otherwise returns {@code def}.
102+
*/
103+
public static String getStringFromInteger(Integer value, String def) {
104+
return (value == null) ? def : String.valueOf((int) value);
105+
}
106+
100107
/**
101108
* Get the {@code hex string} from a {@link byte[]}.
102109
*

termux-shared/src/main/java/com/termux/shared/data/IntentUtils.java

+23
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ public static String getStringExtraIfSet(@NonNull Intent intent, String key, Str
4949
return value;
5050
}
5151

52+
/**
53+
* Get an {@link Integer} from an {@link Intent} stored as a {@link String} extra if its not
54+
* {@code null} or empty.
55+
*
56+
* @param intent The {@link Intent} to get the extra from.
57+
* @param key The {@link String} key name.
58+
* @param def The default value if extra is not set.
59+
* @return Returns the {@link Integer} extra if set, otherwise {@code null}.
60+
*/
61+
public static Integer getIntegerExtraIfSet(@NonNull Intent intent, String key, Integer def) {
62+
try {
63+
String value = intent.getStringExtra(key);
64+
if (value == null || value.isEmpty()) {
65+
return def;
66+
}
67+
68+
return Integer.parseInt(value);
69+
}
70+
catch (Exception e) {
71+
return def;
72+
}
73+
}
74+
5275

5376

5477
/**

termux-shared/src/main/java/com/termux/shared/logger/Logger.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public class Logger {
5050

5151

5252

53-
public static void logMessage(int logLevel, String tag, String message) {
54-
if (logLevel == Log.ERROR && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
53+
public static void logMessage(int logPriority, String tag, String message) {
54+
if (logPriority == Log.ERROR && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
5555
Log.e(getFullTag(tag), message);
56-
else if (logLevel == Log.WARN && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
56+
else if (logPriority == Log.WARN && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
5757
Log.w(getFullTag(tag), message);
58-
else if (logLevel == Log.INFO && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
58+
else if (logPriority == Log.INFO && CURRENT_LOG_LEVEL >= LOG_LEVEL_NORMAL)
5959
Log.i(getFullTag(tag), message);
60-
else if (logLevel == Log.DEBUG && CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
60+
else if (logPriority == Log.DEBUG && CURRENT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
6161
Log.d(getFullTag(tag), message);
62-
else if (logLevel == Log.VERBOSE && CURRENT_LOG_LEVEL >= LOG_LEVEL_VERBOSE)
62+
else if (logPriority == Log.VERBOSE && CURRENT_LOG_LEVEL >= LOG_LEVEL_VERBOSE)
6363
Log.v(getFullTag(tag), message);
6464
}
6565

@@ -187,6 +187,10 @@ public static void logVerboseExtended(String message) {
187187
logExtendedMessage(Log.VERBOSE, DEFAULT_LOG_TAG, message);
188188
}
189189

190+
public static void logVerboseForce(String tag, String message) {
191+
Log.v(tag, message);
192+
}
193+
190194

191195

192196
public static void logErrorAndShowToast(Context context, String tag, String message) {

termux-shared/src/main/java/com/termux/shared/models/ExecutionCommand.java

+17
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ public int getValue() {
8383
/** If the {@link ExecutionCommand} is meant to start a failsafe terminal session. */
8484
public boolean isFailsafe;
8585

86+
/**
87+
* The {@link ExecutionCommand} custom log level for background {@link com.termux.shared.shell.TermuxTask}
88+
* commands. By default, @link com.termux.shared.shell.StreamGobbler} only logs if {@link Logger}
89+
* `CURRENT_LOG_LEVEL` is >= {@link Logger#LOG_LEVEL_VERBOSE}.
90+
*/
91+
public Integer backgroundCustomLogLevel;
8692

8793
/** The session action of foreground commands. */
8894
public String sessionAction;
@@ -264,6 +270,9 @@ public static String getExecutionInputLogString(final ExecutionCommand execution
264270
logString.append("\n").append(executionCommand.getInBackgroundLogString());
265271
logString.append("\n").append(executionCommand.getIsFailsafeLogString());
266272

273+
if (executionCommand.inBackground && (!ignoreNull || executionCommand.backgroundCustomLogLevel != null))
274+
logString.append("\n").append(executionCommand.getBackgroundCustomLogLevelLogString());
275+
267276
if (!ignoreNull || executionCommand.sessionAction != null)
268277
logString.append("\n").append(executionCommand.getSessionActionLogString());
269278

@@ -346,6 +355,10 @@ public static String getExecutionCommandMarkdownString(final ExecutionCommand ex
346355
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Working Directory", executionCommand.workingDirectory, "-"));
347356
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("inBackground", executionCommand.inBackground, "-"));
348357
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("isFailsafe", executionCommand.isFailsafe, "-"));
358+
359+
if (executionCommand.inBackground && executionCommand.backgroundCustomLogLevel != null)
360+
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Background Custom Log Level", executionCommand.backgroundCustomLogLevel, "-"));
361+
349362
markdownString.append("\n").append(MarkdownUtils.getSingleLineMarkdownStringEntry("Session Action", executionCommand.sessionAction, "-"));
350363

351364

@@ -418,6 +431,10 @@ public String getIsFailsafeLogString() {
418431
return "isFailsafe: `" + isFailsafe + "`";
419432
}
420433

434+
public String getBackgroundCustomLogLevelLogString() {
435+
return "Background Custom Log Level: `" + backgroundCustomLogLevel + "`";
436+
}
437+
421438
public String getSessionActionLogString() {
422439
return Logger.getSingleLineLogStringEntry("Session Action", sessionAction, "-");
423440
}

termux-shared/src/main/java/com/termux/shared/shell/StreamGobbler.java

+37-9
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public interface OnStreamClosedListener {
8787
private final OnLineListener lineListener;
8888
@Nullable
8989
private final OnStreamClosedListener streamClosedListener;
90+
@Nullable
91+
private final Integer mLlogLevel;
9092
private volatile boolean active = true;
9193
private volatile boolean calledOnClose = false;
9294

@@ -102,9 +104,13 @@ public interface OnStreamClosedListener {
102104
* @param shell Name of the shell
103105
* @param inputStream InputStream to read from
104106
* @param outputList {@literal List<String>} to write to, or null
107+
* @param logLevel The custom log level to use for logging by command output. If set to
108+
* {@code null}, then {@link Logger#LOG_LEVEL_VERBOSE} will be used.
105109
*/
106110
@AnyThread
107-
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @Nullable List<String> outputList) {
111+
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream,
112+
@Nullable List<String> outputList,
113+
@Nullable Integer logLevel) {
108114
super("Gobbler#" + incThreadCounter());
109115
this.shell = shell;
110116
this.inputStream = inputStream;
@@ -114,6 +120,8 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
114120
listWriter = outputList;
115121
stringWriter = null;
116122
lineListener = null;
123+
124+
mLlogLevel = logLevel;
117125
}
118126

119127
/**
@@ -128,9 +136,13 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
128136
* @param shell Name of the shell
129137
* @param inputStream InputStream to read from
130138
* @param outputString {@literal List<String>} to write to, or null
139+
* @param logLevel The custom log level to use for logging by command output. If set to
140+
* {@code null}, then {@link Logger#LOG_LEVEL_VERBOSE} will be used.
131141
*/
132142
@AnyThread
133-
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @Nullable StringBuilder outputString) {
143+
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream,
144+
@Nullable StringBuilder outputString,
145+
@Nullable Integer logLevel) {
134146
super("Gobbler#" + incThreadCounter());
135147
this.shell = shell;
136148
this.inputStream = inputStream;
@@ -140,6 +152,8 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
140152
listWriter = null;
141153
stringWriter = outputString;
142154
lineListener = null;
155+
156+
mLlogLevel = logLevel;
143157
}
144158

145159
/**
@@ -153,9 +167,14 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
153167
* @param inputStream InputStream to read from
154168
* @param onLineListener OnLineListener callback
155169
* @param onStreamClosedListener OnStreamClosedListener callback
170+
* @param logLevel The custom log level to use for logging by command output. If set to
171+
* {@code null}, then {@link Logger#LOG_LEVEL_VERBOSE} will be used.
156172
*/
157173
@AnyThread
158-
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @Nullable OnLineListener onLineListener, @Nullable OnStreamClosedListener onStreamClosedListener) {
174+
public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream,
175+
@Nullable OnLineListener onLineListener,
176+
@Nullable OnStreamClosedListener onStreamClosedListener,
177+
@Nullable Integer logLevel) {
159178
super("Gobbler#" + incThreadCounter());
160179
this.shell = shell;
161180
this.inputStream = inputStream;
@@ -165,21 +184,30 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
165184
listWriter = null;
166185
stringWriter = null;
167186
lineListener = onLineListener;
187+
188+
mLlogLevel = logLevel;
168189
}
169190

170191
@Override
171192
public void run() {
172-
// keep reading the InputStream until it ends (or an error occurs)
173-
// optionally pausing when a command is executed that consumes the InputStream itself
193+
String defaultLogTag = Logger.DEFAULT_LOG_TAG;
174194
int currentLogLevel = Logger.getLogLevel();
175-
int logLevelVerbose = Logger.LOG_LEVEL_VERBOSE;
176195

196+
int customLogLevel;
197+
if (mLlogLevel != null && mLlogLevel >= Logger.LOG_LEVEL_OFF) {
198+
customLogLevel = mLlogLevel;
199+
Logger.logVerbose(LOG_TAG, "Using custom log level: " + customLogLevel + ", current log level: " + currentLogLevel);
200+
} else {
201+
customLogLevel = Logger.LOG_LEVEL_VERBOSE;
202+
}
203+
204+
// keep reading the InputStream until it ends (or an error occurs)
205+
// optionally pausing when a command is executed that consumes the InputStream itself
177206
try {
178207
String line;
179208
while ((line = reader.readLine()) != null) {
180-
181-
if (currentLogLevel >= logLevelVerbose)
182-
Logger.logVerbose(LOG_TAG, String.format(Locale.ENGLISH, "[%s] %s", shell, line)); // This will get truncated by LOGGER_ENTRY_MAX_LEN, likely 4KB
209+
if (customLogLevel >= currentLogLevel)
210+
Logger.logVerboseForce(defaultLogTag + "Command", String.format(Locale.ENGLISH, "[%s] %s", shell, line)); // This will get truncated by LOGGER_ENTRY_MAX_LEN, likely 4KB
183211

184212
if (stringWriter != null) stringWriter.append(line).append("\n");
185213
if (listWriter != null) listWriter.add(line);

termux-shared/src/main/java/com/termux/shared/shell/TermuxTask.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ private void executeInner(@NonNull final Context context) throws IllegalThreadSt
139139

140140
// setup stdin, and stdout and stderr gobblers
141141
DataOutputStream STDIN = new DataOutputStream(mProcess.getOutputStream());
142-
StreamGobbler STDOUT = new StreamGobbler(pid + "-stdout", mProcess.getInputStream(), mExecutionCommand.resultData.stdout);
143-
StreamGobbler STDERR = new StreamGobbler(pid + "-stderr", mProcess.getErrorStream(), mExecutionCommand.resultData.stderr);
142+
StreamGobbler STDOUT = new StreamGobbler(pid + "-stdout", mProcess.getInputStream(), mExecutionCommand.resultData.stdout, mExecutionCommand.backgroundCustomLogLevel);
143+
StreamGobbler STDERR = new StreamGobbler(pid + "-stderr", mProcess.getErrorStream(), mExecutionCommand.resultData.stderr, mExecutionCommand.backgroundCustomLogLevel);
144144

145145
// start gobbling
146146
STDOUT.start();

termux-shared/src/main/java/com/termux/shared/termux/TermuxConstants.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.List;
1313

1414
/*
15-
* Version: v0.24.0
15+
* Version: v0.25.0
1616
*
1717
* Changelog
1818
*
@@ -172,6 +172,12 @@
172172
* `FORMAT_FAILED_ERR__ERRMSG__STDOUT__STDERR__EXIT_CODE`,
173173
* `RESULT_FILE_ERR_PREFIX`, `RESULT_FILE_ERRMSG_PREFIX` `RESULT_FILE_STDOUT_PREFIX`,
174174
* `RESULT_FILE_STDERR_PREFIX`, `RESULT_FILE_EXIT_CODE_PREFIX`.
175+
*
176+
* - 0.25.0 (2021-08-19)
177+
* - Added following to `TERMUX_APP.TERMUX_SERVICE`:
178+
* `EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL`.
179+
* - Added following to `TERMUX_APP.RUN_COMMAND_SERVICE`:
180+
* `EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL`.
175181
*/
176182

177183
/**
@@ -816,6 +822,8 @@ public static final class TERMUX_SERVICE {
816822
public static final String EXTRA_WORKDIR = TERMUX_PACKAGE_NAME + ".execute.cwd"; // Default: "com.termux.execute.cwd"
817823
/** Intent {@code boolean} extra for command background mode for the TERMUX_SERVICE.ACTION_SERVICE_EXECUTE intent */
818824
public static final String EXTRA_BACKGROUND = TERMUX_PACKAGE_NAME + ".execute.background"; // Default: "com.termux.execute.background"
825+
/** Intent {@code String} extra for custom log level for background commands defined by {@link com.termux.shared.logger.Logger} for the TERMUX_SERVICE.ACTION_SERVICE_EXECUTE intent */
826+
public static final String EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL = TERMUX_PACKAGE_NAME + ".execute.background_custom_log_level"; // Default: "com.termux.execute.background_custom_log_level"
819827
/** Intent {@code String} extra for session action for foreground commands for the TERMUX_SERVICE.ACTION_SERVICE_EXECUTE intent */
820828
public static final String EXTRA_SESSION_ACTION = TERMUX_PACKAGE_NAME + ".execute.session_action"; // Default: "com.termux.execute.session_action"
821829
/** Intent {@code String} extra for label of the command for the TERMUX_SERVICE.ACTION_SERVICE_EXECUTE intent */
@@ -939,6 +947,8 @@ public static final class RUN_COMMAND_SERVICE {
939947
public static final String EXTRA_WORKDIR = TERMUX_PACKAGE_NAME + ".RUN_COMMAND_WORKDIR"; // Default: "com.termux.RUN_COMMAND_WORKDIR"
940948
/** Intent {@code boolean} extra for whether to run command in background or foreground terminal session for the RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND intent */
941949
public static final String EXTRA_BACKGROUND = TERMUX_PACKAGE_NAME + ".RUN_COMMAND_BACKGROUND"; // Default: "com.termux.RUN_COMMAND_BACKGROUND"
950+
/** Intent {@code String} extra for custom log level for background commands defined by {@link com.termux.shared.logger.Logger} for the RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND intent */
951+
public static final String EXTRA_BACKGROUND_CUSTOM_LOG_LEVEL = TERMUX_PACKAGE_NAME + ".RUN_COMMAND_BACKGROUND_CUSTOM_LOG_LEVEL"; // Default: "com.termux.RUN_COMMAND_BACKGROUND_CUSTOM_LOG_LEVEL"
942952
/** Intent {@code String} extra for session action of foreground commands for the RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND intent */
943953
public static final String EXTRA_SESSION_ACTION = TERMUX_PACKAGE_NAME + ".RUN_COMMAND_SESSION_ACTION"; // Default: "com.termux.RUN_COMMAND_SESSION_ACTION"
944954
/** Intent {@code String} extra for label of the command for the RUN_COMMAND_SERVICE.ACTION_RUN_COMMAND intent */

termux-shared/src/main/java/com/termux/shared/termux/TermuxUtils.java

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ public static String geAPTInfoMarkdownString(@NonNull final Context context) {
341341
aptInfoScript = aptInfoScript.replaceAll(Pattern.quote("@TERMUX_PREFIX@"), TermuxConstants.TERMUX_PREFIX_DIR_PATH);
342342

343343
ExecutionCommand executionCommand = new ExecutionCommand(1, TermuxConstants.TERMUX_BIN_PREFIX_DIR_PATH + "/bash", null, aptInfoScript, null, true, false);
344+
executionCommand.backgroundCustomLogLevel = Logger.LOG_LEVEL_OFF;
344345
TermuxTask termuxTask = TermuxTask.execute(context, executionCommand, null, new TermuxShellEnvironmentClient(), true);
345346
if (termuxTask == null || !executionCommand.isSuccessful() || executionCommand.resultData.exitCode != 0) {
346347
Logger.logError(LOG_TAG, executionCommand.toString());

0 commit comments

Comments
 (0)