Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ class GradleBuildService :
val reader = input.bufferedReader()
try {
reader.forEachLine { line ->
SERVER_System_err.error(line)
SERVER_System_err.debug(line)
if (!isActive) throw CancellationException()
}
} catch (e: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.itsaky.androidide.tooling.api.IToolingApiServer
import com.itsaky.androidide.tooling.api.util.ToolingApiLauncher
import com.itsaky.androidide.tooling.api.util.ToolingProps
import com.itsaky.androidide.utils.Environment
import com.itsaky.androidide.utils.FeatureFlags
import com.termux.shared.reflection.ReflectionUtils
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineName
Expand Down Expand Up @@ -67,7 +68,7 @@ internal class ToolingServerRunner(
/**
* Whether to enable logging of the error stream of the tooling server.
*/
const val TOOLING_ERR_STREAM_LOGGING_ENABLED = true
val TOOLING_ERR_STREAM_LOGGING_ENABLED = FeatureFlags.isDebugLoggingEnabled

/**
* Whether to enable force killing the Gradle daemon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,30 @@

package com.itsaky.androidide.logging;

import ch.qos.logback.classic.spi.ILoggingEvent;
import com.itsaky.androidide.logging.utils.LogUtils;

/**
* @author Akash Yadav
*/
public class JvmStdErrAppender extends StdErrAppender {

public static final String PROP_JVM_STDERR_APPENDER_ENABLED = "ide.logging.jvmStdErrAppenderEnabled";
public static final String PROP_JVM_STDERR_APPENDER_ENABLED = "ide.logging.jvmStdErrAppenderEnabled";

private boolean isJvm = false; // JvmStdErrAppender is disabled by default
private boolean jvmStdErrAppenderEnabled = true;

@Override
public void start() {
this.isJvm = LogUtils.isJvm();
super.start();
}
@Override
public void start() {
jvmStdErrAppenderEnabled = Boolean.parseBoolean(
System.getProperty(PROP_JVM_STDERR_APPENDER_ENABLED, "true"));
jvmStdErrAppenderEnabled &= LogUtils.isJvm();
super.start();
}

@Override
public boolean isStarted() {
return super.isStarted()
&& isJvm
&& Boolean.parseBoolean(System.getProperty(PROP_JVM_STDERR_APPENDER_ENABLED, "true"));
}
@Override
protected void append(ILoggingEvent eventObject) {
if (!jvmStdErrAppenderEnabled)
return;
super.append(eventObject);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ object ProjectSyncHelper {
* @param projectDir The project directory.
* @return The sync metadata file.
*/
fun syncMetaFileForProject(projectDir: File) =
projectDir.resolve(SharedEnvironment.PROJECT_SYNC_CACHE_META_FILE)
fun syncMetaFileForProject(projectDir: File) = projectDir.resolve(SharedEnvironment.PROJECT_SYNC_CACHE_META_FILE)

/**
* Try to acquire the sync lock.
Expand Down Expand Up @@ -197,7 +196,6 @@ object ProjectSyncHelper {
// /data/data and /sdcard are different devices (partitions)
// atomic moves are not possible for cross-device moves
val tempCacheFile = Paths.get(targetFile.path + ".tmp")
logger.debug("Write project model to file: {}", tempCacheFile)
runCatching {
tempCacheFile
.outputStream(StandardOpenOption.CREATE, StandardOpenOption.WRITE)
Expand All @@ -206,9 +204,7 @@ object ProjectSyncHelper {
gradleBuild.writeTo(tempOut)
tempOut.flush()
}
logger.debug("Wrote file {}", tempCacheFile)
}.map {
logger.debug("Moving {} to {}", tempCacheFile, targetFile)
// update atomically
Files.move(
tempCacheFile,
Expand All @@ -226,10 +222,11 @@ object ProjectSyncHelper {
* @param projectDir The project directory.
* @return `true` if the files exist and are readable, `false` otherwise.
*/
fun areSyncFilesReadable(projectDir: File) = areSyncFilesReadable(
syncMetaFile = syncMetaFileForProject(projectDir),
projectCacheFile = cacheFileForProject(projectDir)
)
fun areSyncFilesReadable(projectDir: File) =
areSyncFilesReadable(
syncMetaFile = syncMetaFileForProject(projectDir),
projectCacheFile = cacheFileForProject(projectDir),
)

/**
* Check whether the project sync files for the given project directory
Expand All @@ -242,10 +239,11 @@ object ProjectSyncHelper {
fun areSyncFilesReadable(
syncMetaFile: File,
projectCacheFile: File,
): Boolean {
return syncMetaFile.exists() && syncMetaFile.canRead() &&
projectCacheFile.exists() && projectCacheFile.canRead()
}
): Boolean =
syncMetaFile.exists() &&
syncMetaFile.canRead() &&
projectCacheFile.exists() &&
projectCacheFile.canRead()

/**
* Check if a sync is needed for the given project directory.
Expand All @@ -263,10 +261,10 @@ object ProjectSyncHelper {
// one of the required files are missing, require sync
logger.debug(
"NEED_SYNC: sync files missing or are unreadable:" +
" sync-meta={}," +
" project-cache={}",
" sync-meta={}," +
" project-cache={}",
syncMetaFile,
projectCacheFile
projectCacheFile,
)
return true
}
Expand Down