From a0b6343fcadf9d762381e3870dff8bcaf56bc4d5 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 23 Sep 2009 15:47:32 +0400 Subject: [PATCH] follow Mac convention for log files location --- bin/log.xml | 4 ++-- build/conf/mac/Contents/Info.plist | 2 ++ .../src/com/intellij/idea/LoggerFactory.java | 4 ++-- .../src/com/intellij/idea/SocketLock.java | 2 +- .../openapi/application/PathManager.java | 16 ++++++++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/bin/log.xml b/bin/log.xml index d2e12a68ecfc..a156e2755b79 100644 --- a/bin/log.xml +++ b/bin/log.xml @@ -37,7 +37,7 @@ - + @@ -46,7 +46,7 @@ - + diff --git a/build/conf/mac/Contents/Info.plist b/build/conf/mac/Contents/Info.plist index 6f2aebc5440f..d650d2da29a6 100644 --- a/build/conf/mac/Contents/Info.plist +++ b/build/conf/mac/Contents/Info.plist @@ -75,6 +75,8 @@ ~/Library/Caches/@@system_selector@@/ idea.plugins.path ~/Library/Application Support/@@system_selector@@/ + idea.log.path + ~/Library/Logs/@@system_selector@@/ java.endorsed.dirs idea.smooth.progress diff --git a/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java b/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java index 0e17ba69ca23..a59cb4d3be86 100644 --- a/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java +++ b/platform/platform-impl/src/com/intellij/idea/LoggerFactory.java @@ -64,13 +64,13 @@ public class LoggerFactory implements Logger.Factory { String text = new String(FileUtil.loadFileText(logXmlFile)); text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\")); text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\")); - text = StringUtil.replace(text, LOGDIR_MACRO, StringUtil.replace(LOG_DIR, "\\", "\\\\")); + text = StringUtil.replace(text, LOGDIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\")); if ("true".equals(System.getProperty("idea.test.test_mode"))) { text = commentTestModeLines(text); } - File file = new File(new File(PathManager.getSystemPath()), LOG_DIR); + File file = new File(PathManager.getLogPath()); file.mkdirs(); new DOMConfigurator().doConfigure(new StringReader(text), LogManager.getLoggerRepository()); diff --git a/platform/platform-impl/src/com/intellij/idea/SocketLock.java b/platform/platform-impl/src/com/intellij/idea/SocketLock.java index 19f043bae5e7..505c23923baa 100644 --- a/platform/platform-impl/src/com/intellij/idea/SocketLock.java +++ b/platform/platform-impl/src/com/intellij/idea/SocketLock.java @@ -62,7 +62,7 @@ public class SocketLock { if (StartupUtil.isHeadless()) { //team server inspections throw new RuntimeException("Only one instance of " + productName + " can be run at a time."); } - @NonNls final String pathToLogFile = PathManager.getSystemPath() + "/log/idea.log file".replace('/', File.separatorChar); + @NonNls final String pathToLogFile = PathManager.getLogPath() + "/idea.log file".replace('/', File.separatorChar); JOptionPane.showMessageDialog( JOptionPane.getRootFrame(), CommonBundle.message("cannot.start.other.instance.is.running.error.message", productName, pathToLogFile), diff --git a/platform/util/src/com/intellij/openapi/application/PathManager.java b/platform/util/src/com/intellij/openapi/application/PathManager.java index 6922b39293c5..135362f18c51 100644 --- a/platform/util/src/com/intellij/openapi/application/PathManager.java +++ b/platform/util/src/com/intellij/openapi/application/PathManager.java @@ -38,11 +38,13 @@ public class PathManager { @NonNls private static final String PROPERTY_CONFIG_PATH = "idea.config.path"; @NonNls private static final String PROPERTY_PLUGINS_PATH = "idea.plugins.path"; @NonNls private static final String PROPERTY_HOME_PATH = "idea.home.path"; + @NonNls private static final String PROPERTY_LOG_PATH = "idea.log.path"; @NonNls private static String ourHomePath; @NonNls private static String ourSystemPath; @NonNls private static String ourConfigPath; @NonNls private static String ourPluginsPath; + @NonNls private static String ourLogPath; @NonNls private static final String FILE = "file"; @NonNls private static final String JAR = "jar"; @@ -52,6 +54,7 @@ public class PathManager { @NonNls private static final String LIB_FOLDER = "lib"; @NonNls public static final String PLUGINS_DIRECTORY = "plugins"; @NonNls private static final String BIN_FOLDER = "bin"; + @NonNls private static final String LOG_DIRECTORY = "log"; @NonNls private static final String OPTIONS_FOLDER = "options"; public static String getHomePath() { @@ -206,6 +209,19 @@ public class PathManager { return ourPluginsPath; } + public static String getLogPath() { + if (ourLogPath == null) { + if (System.getProperty(PROPERTY_LOG_PATH) != null) { + ourLogPath = getAbsolutePath(trimPathQuotes(System.getProperty(PROPERTY_LOG_PATH))); + } + else { + ourLogPath = getSystemPath() + File.separatorChar + LOG_DIRECTORY; + } + } + + return ourLogPath; + } + private static String getAbsolutePath(String path) { if (path.startsWith("~/") || path.startsWith("~\\")) { path = SystemProperties.getUserHome() + path.substring(1);