Search in sources :

Example 6 with Logger

use of com.intellij.openapi.diagnostic.Logger in project intellij-community by JetBrains.

the class StartupUtil method prepareAndStart.

static void prepareAndStart(String[] args, AppStarter appStarter) {
    boolean newConfigFolder = false;
    if (!Main.isHeadless()) {
        AppUIUtil.updateFrameClass();
        newConfigFolder = !new File(PathManager.getConfigPath()).exists();
    }
    if (!checkJdkVersion()) {
        System.exit(Main.JDK_CHECK_FAILED);
    }
    // avoiding "log4j:WARN No appenders could be found"
    System.setProperty("log4j.defaultInitOverride", "true");
    try {
        org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger();
        if (!root.getAllAppenders().hasMoreElements()) {
            root.setLevel(Level.WARN);
            root.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.DEFAULT_CONVERSION_PATTERN)));
        }
    } catch (Throwable e) {
        //noinspection CallToPrintStackTrace
        e.printStackTrace();
    }
    // note: uses config folder!
    if (!checkSystemFolders()) {
        System.exit(Main.DIR_CHECK_FAILED);
    }
    ActivationResult result = lockSystemFolders(args);
    if (result == ActivationResult.ACTIVATED) {
        System.exit(0);
    } else if (result != ActivationResult.STARTED) {
        System.exit(Main.INSTANCE_CHECK_FAILED);
    }
    if (newConfigFolder) {
        appStarter.beforeImportConfigs();
        ConfigImportHelper.importConfigsTo(PathManager.getConfigPath());
    }
    Logger.setFactory(LoggerFactory.class);
    Logger log = Logger.getInstance(Main.class);
    startLogging(log);
    loadSystemLibraries(log);
    fixProcessEnvironment(log);
    if (!Main.isHeadless()) {
        AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
        AppUIUtil.registerBundledFonts();
        AppUIUtil.showPrivacyPolicy();
    }
    appStarter.start(newConfigFolder);
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) PatternLayout(org.apache.log4j.PatternLayout) Logger(com.intellij.openapi.diagnostic.Logger) File(java.io.File)

Example 7 with Logger

use of com.intellij.openapi.diagnostic.Logger in project intellij-community by JetBrains.

the class ReplacerUtil method copySpacesAndCommentsBefore.

public static PsiElement copySpacesAndCommentsBefore(PsiElement elementToReplace, PsiElement[] patternElements, String replacementToMake, PsiElement elementParent) {
    int i = 0;
    while (true) {
        // if it goes out of bounds then deep error happens
        if (!(patternElements[i] instanceof PsiComment || patternElements[i] instanceof PsiWhiteSpace)) {
            break;
        }
        ++i;
        if (patternElements.length == i) {
            break;
        }
    }
    if (patternElements.length == i) {
        Logger logger = Logger.getInstance(StructuralSearchProfile.class.getName());
        logger.error("Unexpected replacement structure:" + replacementToMake);
    }
    if (i != 0) {
        elementParent.addRangeBefore(patternElements[0], patternElements[i - 1], elementToReplace);
    }
    return patternElements[i];
}
Also used : PsiComment(com.intellij.psi.PsiComment) StructuralSearchProfile(com.intellij.structuralsearch.StructuralSearchProfile) Logger(com.intellij.openapi.diagnostic.Logger) PsiWhiteSpace(com.intellij.psi.PsiWhiteSpace)

Example 8 with Logger

use of com.intellij.openapi.diagnostic.Logger in project intellij-community by JetBrains.

the class TestLoggerFactory method enableDebugLogging.

public static void enableDebugLogging(@NotNull Disposable parentDisposable, @NotNull String... categories) {
    for (String category : categories) {
        final Logger logger = Logger.getInstance(category);
        logger.setLevel(Level.DEBUG);
        Disposer.register(parentDisposable, () -> logger.setLevel(Level.INFO));
    }
}
Also used : Logger(com.intellij.openapi.diagnostic.Logger)

Example 9 with Logger

use of com.intellij.openapi.diagnostic.Logger in project android by JetBrains.

the class EmbeddedDistributionPaths method findEmbeddedGradleDistributionPath.

@Nullable
public File findEmbeddedGradleDistributionPath() {
    File distributionPath = getDefaultRootDirPath();
    if (distributionPath != null) {
        // Release build
        Logger log = getLog();
        File embeddedPath = new File(distributionPath, "gradle-" + GRADLE_LATEST_VERSION);
        log.info("Looking for embedded Gradle distribution at '" + embeddedPath.getPath() + "'");
        if (embeddedPath.isDirectory()) {
            log.info("Found embedded Gradle " + GRADLE_LATEST_VERSION);
            return embeddedPath;
        }
        log.info("Unable to find embedded Gradle " + GRADLE_LATEST_VERSION);
        return null;
    }
    // Development build.
    String ideHomePath = getIdeHomePath();
    String relativePath = toSystemDependentName("/../../out/gradle-dist-link");
    distributionPath = new File(toCanonicalPath(ideHomePath + relativePath));
    return distributionPath.isDirectory() ? distributionPath : null;
}
Also used : Logger(com.intellij.openapi.diagnostic.Logger) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with Logger

use of com.intellij.openapi.diagnostic.Logger in project android by JetBrains.

the class ShellCommandLauncher method execute.

public static boolean execute(@NotNull String command, @NotNull IDevice device, @NotNull LaunchStatus launchStatus, @NotNull ConsolePrinter printer, long timeout, @NotNull TimeUnit timeoutUnit) {
    printer.stdout("$ adb shell " + command);
    CollectingOutputReceiver receiver = new AndroidLaunchReceiver(launchStatus);
    try {
        device.executeShellCommand(command, receiver, timeout, timeoutUnit);
    } catch (Exception e) {
        Logger logger = Logger.getInstance(ShellCommandLauncher.class);
        logger.warn("Unexpected exception while executing shell command: " + command);
        logger.warn(e);
        launchStatus.terminateLaunch("Unexpected error while executing: " + command);
        return false;
    }
    String output = receiver.getOutput();
    if (output.toLowerCase(Locale.US).contains("error")) {
        launchStatus.terminateLaunch("Error while executing: " + command);
        printer.stderr(output);
        return false;
    }
    return true;
}
Also used : CollectingOutputReceiver(com.android.ddmlib.CollectingOutputReceiver) Logger(com.intellij.openapi.diagnostic.Logger)

Aggregations

Logger (com.intellij.openapi.diagnostic.Logger)17 Nullable (org.jetbrains.annotations.Nullable)5 File (java.io.File)3 StringUtil (com.intellij.openapi.util.text.StringUtil)2 IOException (java.io.IOException)2 java.util (java.util)2 NotNull (org.jetbrains.annotations.NotNull)2 SdkConstants (com.android.SdkConstants)1 VisibleForTesting (com.android.annotations.VisibleForTesting)1 CollectingOutputReceiver (com.android.ddmlib.CollectingOutputReceiver)1 LayoutLog (com.android.ide.common.rendering.api.LayoutLog)1 TAG_RESOURCES_PREFIX (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_PREFIX)1 TAG_RESOURCES_RESOLVE_THEME_ATTR (com.android.ide.common.rendering.api.LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR)1 ResourceResolver (com.android.ide.common.resources.ResourceResolver)1 RenderSessionImpl (com.android.layoutlib.bridge.impl.RenderSessionImpl)1 Density (com.android.resources.Density)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 TAG_STILL_BUILDING (com.android.tools.idea.rendering.RenderLogger.TAG_STILL_BUILDING)1 RenderErrorModel (com.android.tools.idea.rendering.errors.ui.RenderErrorModel)1