make "Registry values changed by user" logging more compact

GitOrigin-RevId: 241365f2d8f366c8fab2eba1a4bac48b9824556d
This commit is contained in:
Vladimir Krivosheev
2019-07-31 22:02:49 +03:00
committed by intellij-monorepo-bot
parent 395ac2a134
commit 3a73782bb6
2 changed files with 16 additions and 10 deletions
@@ -8,17 +8,17 @@ import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtilRt;
import com.intellij.util.SmartList;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
@State(name = "Registry", storages = @Storage("ide.general.xml"))
public final class RegistryState implements PersistentStateComponent<Element> {
final class RegistryState implements PersistentStateComponent<Element> {
private static final Logger LOG = Logger.getInstance(RegistryState.class);
@Override
@@ -30,13 +30,19 @@ public final class RegistryState implements PersistentStateComponent<Element> {
public void loadState(@NotNull Element state) {
Registry.getInstance().loadState(state);
SortedMap<String, String> userProperties = new TreeMap<>(Registry.getInstance().getUserProperties());
userProperties.remove("ide.firstStartup");
if (!userProperties.isEmpty()) {
LOG.info("Registry values changed by user:");
for (Map.Entry<String, String> entry : userProperties.entrySet()) {
LOG.info(" " + entry.getKey() + " = " + entry.getValue());
Map<String, String> userProperties = Registry.getInstance().getUserProperties();
if (userProperties.size() > (userProperties.containsKey("ide.firstStartup") ? 1 : 0)) {
String[] keys = ArrayUtilRt.toStringArray(userProperties.keySet());
Arrays.sort(keys);
StringBuilder builder = new StringBuilder("Registry values changed by user: ");
for (String key : keys) {
if ("ide.firstStartup".equals(key)) {
continue;
}
builder.append(key).append(" = ").append(userProperties.get(key)).append(", ");
}
LOG.info(builder.substring(0, builder.length() - 2));
}
// make logging for experimental features here to have registry + experiments together in the log file
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
* Provides a UI to configure internal settings of the IDE. Plugins can provide their own registry keys using the
* {@code <registryKey>} extension point (see {@link com.intellij.openapi.util.registry.RegistryKeyBean} for more details).
*/
public class Registry {
public final class Registry {
private static Reference<ResourceBundle> ourBundle;
@NonNls