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);
}
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];
}
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));
}
}
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;
}
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;
}
Aggregations