Skip to content

Commit

Permalink
Micro optimization for StreamGobbler
Browse files Browse the repository at this point in the history
  • Loading branch information
agnostic-apollo committed Apr 9, 2021
1 parent 62a2104 commit 0c9b85a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ public StreamGobbler(@NonNull String shell, @NonNull InputStream inputStream, @N
public void run() {
// keep reading the InputStream until it ends (or an error occurs)
// optionally pausing when a command is executed that consumes the InputStream itself
int logLevel = Logger.getLogLevel();
int currentLogLevel = Logger.getLogLevel();
int logLevelVerbose = Logger.LOG_LEVEL_VERBOSE;
try {
String line;
while ((line = reader.readLine()) != null) {

if(logLevel >= Logger.LOG_LEVEL_VERBOSE)
if(currentLogLevel >= logLevelVerbose)
Logger.logVerbose(LOG_TAG, String.format(Locale.ENGLISH, "[%s] %s", shell, line)); // This will get truncated by LOGGER_ENTRY_MAX_LEN, likely 4KB

if (stringWriter != null) stringWriter.append(line).append("\n");
Expand Down

0 comments on commit 0c9b85a

Please sign in to comment.