diff --git a/app/src/main/java/io/xpipe/app/core/AppDebugModeNotice.java b/app/src/main/java/io/xpipe/app/core/AppDebugModeNotice.java new file mode 100644 index 00000000..239cf1a3 --- /dev/null +++ b/app/src/main/java/io/xpipe/app/core/AppDebugModeNotice.java @@ -0,0 +1,27 @@ +package io.xpipe.app.core; + +import io.xpipe.app.util.ThreadHelper; +import io.xpipe.core.util.ModuleHelper; + +public class AppDebugModeNotice { + + public static void printIfNeeded() { + if (!ModuleHelper.isImage() || !AppLogs.get().getLogLevel().equals("trace")) { + return; + } + + var out = AppLogs.get().getOriginalSysOut(); + var msg = """ + + **************************************** + * You are running XPipe in debug mode! * + * The debug console output can contain * + * sensitive information and secrets. * + * Don't share this output via an * + * untrusted website or service. * + **************************************** + """; + out.println(msg); + ThreadHelper.sleep(1000); + } +} diff --git a/app/src/main/java/io/xpipe/app/core/AppLogs.java b/app/src/main/java/io/xpipe/app/core/AppLogs.java index 1b98fd24..3a30abad 100644 --- a/app/src/main/java/io/xpipe/app/core/AppLogs.java +++ b/app/src/main/java/io/xpipe/app/core/AppLogs.java @@ -2,8 +2,10 @@ package io.xpipe.app.core; import io.xpipe.app.issue.ErrorEvent; import io.xpipe.app.issue.TrackEvent; +import io.xpipe.app.util.XPipeSession; import io.xpipe.core.util.Deobfuscator; import lombok.Getter; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.slf4j.ILoggerFactory; import org.slf4j.IMarkerFactory; @@ -35,7 +37,7 @@ public class AppLogs { private static final String WRITE_LOGS_PROP = "io.xpipe.app.writeLogs"; private static final String DEBUG_PLATFORM_PROP = "io.xpipe.app.debugPlatform"; private static final String LOG_LEVEL_PROP = "io.xpipe.app.logLevel"; - private static final String DEFAULT_LOG_LEVEL = "debug"; + private static final String DEFAULT_LOG_LEVEL = "info"; private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss").withZone(ZoneId.systemDefault()); @@ -95,6 +97,15 @@ public class AppLogs { public static void init() { var logDir = AppProperties.get().getDataDir().resolve("logs"); + + if (XPipeSession.get().isNewBuildSession()) { + try { + FileUtils.cleanDirectory(logDir.toFile()); + } catch (Exception ex) { + ErrorEvent.fromThrowable(ex).handle(); + } + } + var shouldLogToFile = shouldWriteLogs(); var now = Instant.now(); @@ -236,8 +247,8 @@ public class AppLogs { private static String determineLogLevel() { if (System.getProperty(LOG_LEVEL_PROP) != null) { - String p = System.getProperty(WRITE_SYSOUT_PROP); - return DEFAULT_LEVELS.contains(p) ? p : "trace"; + String p = System.getProperty(LOG_LEVEL_PROP); + return DEFAULT_LEVELS.contains(p) ? p : "info"; } return DEFAULT_LOG_LEVEL; diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index ce76cc08..266b03dd 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -100,6 +100,7 @@ public abstract class OperationMode { AppUserDirectoryCheck.check(); AppTempCheck.check(); AppLogs.init(); + AppDebugModeNotice.printIfNeeded(); AppProperties.logArguments(args); AppProperties.logSystemProperties(); AppProperties.logPassedProperties(); diff --git a/core/src/main/java/io/xpipe/core/process/CommandControl.java b/core/src/main/java/io/xpipe/core/process/CommandControl.java index c487d007..879c90bd 100644 --- a/core/src/main/java/io/xpipe/core/process/CommandControl.java +++ b/core/src/main/java/io/xpipe/core/process/CommandControl.java @@ -26,6 +26,8 @@ public interface CommandControl extends ProcessControl { CLOSE } + void setSensitive(); + CommandControl withExceptionConverter(ExceptionConverter converter); CommandControl withErrorFormatter(Function formatter);