Java Code Examples for consulo.logging.Logger#info()

The following examples show how to use consulo.logging.Logger#info() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void logAndClose(@Nonnull Throwable error, @Nonnull Logger log, @Nonnull Channel channel) {
  // don't report about errors while connecting
  // WEB-7727
  try {
    if (error instanceof ConnectException) {
      log.debug(error);
    }
    else {
      log(error, log);
    }
  }
  finally {
    log.info("Channel will be closed due to error");
    channel.close();
  }
}
 
Example 2
Source File: StartupUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void logStartupInfo(final Logger log) {
  LoggerFactory factory = LoggerFactoryInitializer.getFactory();

  Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") {
    @Override
    public void run() {
      log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
      factory.shutdown();
    }
  });
  log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------");
  log.info("Using logger factory: " + factory.getClass().getSimpleName());

  ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance();
  ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
  String buildDate = new SimpleDateFormat("dd MMM yyyy HH:ss", Locale.US).format(appInfo.getBuildDate().getTime());
  log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " + buildDate + ")");
  log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ", " + SystemInfo.OS_ARCH + ")");
  log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")");
  log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")");

  List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
  if (arguments != null) {
    log.info("JVM Args: " + StringUtil.join(arguments, " "));
  }
}
 
Example 3
Source File: ProcessOutput.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * If exit code is nonzero or the process timed out, logs stderr and exit code and returns false,
 * else just returns true.
 *
 * @param logger where to put error information
 * @return true iff exit code is zero
 */
public boolean checkSuccess(@Nonnull final Logger logger) {
  if (getExitCode() != 0 || isTimeout()) {
    logger.info(getStderr() + (isTimeout() ? "\nTimed out" : "\nExit code " + getExitCode()));
    return false;
  }
  return true;
}
 
Example 4
Source File: SystemNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Notifier getPlatformNotifier() {
  try {
    if (SystemInfo.isMac) {
      if (SystemInfo.isMacOSMountainLion && SystemProperties.getBooleanProperty("ide.mac.mountain.lion.notifications.enabled", true)) {
        return MountainLionNotifications.getInstance();
      }
      else {
        return GrowlNotifications.getInstance();
      }
    }
    else if (SystemInfo.isXWindow) {
      return LibNotifyWrapper.getInstance();
    }
    else if (SystemInfo.isWin10OrNewer) {
      return SystemTrayNotifications.getWin10Instance();
    }
  }
  catch (Throwable t) {
    Logger logger = Logger.getInstance(SystemNotifications.class);
    if (logger.isDebugEnabled()) {
      logger.debug(t);
    }
    else {
      logger.info(t.getMessage());
    }
  }

  return null;
}
 
Example 5
Source File: StartupUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void fixProcessEnvironment(Logger log) {
  System.setProperty("__idea.mac.env.lock", "unlocked");

  boolean envReady = EnvironmentUtil.isEnvironmentReady();  // trigger environment loading
  if (!envReady) {
    log.info("initializing environment");
  }
}
 
Example 6
Source File: AbstractLayoutCodeProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @Nonnull PsiFile file) {
  logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e);
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    Notification notification =
            new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"),
                             ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()), NotificationType.INFORMATION);
    notification.notify(file.getProject());
  }
}
 
Example 7
Source File: RegExHelpPopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static LinkLabel createRegExLink(@Nonnull String title, @Nullable final Component owner, @Nullable final Logger logger) {
  return new LinkLabel(title, null, new LinkListener() {
    JBPopup helpPopup;
    @Override
    public void linkSelected(LinkLabel aSource, Object aLinkData) {
      try {
        if (helpPopup != null && !helpPopup.isDisposed() && helpPopup.isVisible()) {
          return;
        }
        helpPopup = createRegExHelpPopup();
        Disposer.register(helpPopup, new Disposable() {
          @Override
          public void dispose() {
            destroyPopup();
          }
        });
        helpPopup.showInCenterOf(owner);
      }
      catch (BadLocationException e) {
        if (logger != null) logger.info(e);
      }
    }

    private void destroyPopup() {
      helpPopup = null;
    }
  });
}
 
Example 8
Source File: IndicesRegistrationResult.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void logChangedAndFullyBuiltIndices(@Nonnull Logger log, @Nonnull String changedIndicesLogMessage, @Nonnull String fullyBuiltIndicesLogMessage) {
  String changedIndices = changedIndices();
  if (!changedIndices.isEmpty()) {
    log.info(changedIndicesLogMessage + changedIndices);
  }
  String fullyBuiltIndices = fullyBuiltIndices();
  if (!fullyBuiltIndices.isEmpty()) {
    log.info(fullyBuiltIndicesLogMessage + fullyBuiltIndices);
  }
}
 
Example 9
Source File: JBUIScale.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private static Pair<String, Integer> calcSystemFontData() {
  // with JB Linux JDK the label font comes properly scaled based on Xft.dpi settings.
  Font font = UIManager.getFont("Label.font");
  if (SystemInfo.isMacOSElCapitan) {
    // text family should be used for relatively small sizes (<20pt), don't change to Display
    // see more about SF https://medium.com/@mach/the-secret-of-san-francisco-fonts-4b5295d9a745#.2ndr50z2v
    font = new Font(".SF NS Text", font.getStyle(), font.getSize());
  }

  Logger log = getLogger();
  boolean isScaleVerbose = Boolean.getBoolean("ide.ui.scale.verbose");
  if (isScaleVerbose) {
    log.info(String.format("Label font: %s, %d", font.getFontName(), font.getSize()));
  }

  if (SystemInfo.isLinux) {
    Object value = Toolkit.getDefaultToolkit().getDesktopProperty("gnome.Xft/DPI");
    if (isScaleVerbose) {
      log.info(String.format("gnome.Xft/DPI: %s", value));
    }
    if (value instanceof Integer) { // defined by JB JDK when the resource is available in the system
      // If the property is defined, then:
      // 1) it provides correct system scale
      // 2) the label font size is scaled
      int dpi = ((Integer)value).intValue() / 1024;
      if (dpi < 50) dpi = 50;
      float scale = JreHiDpiUtil.isJreHiDPIEnabled() ? 1f : discreteScale(dpi / 96f); // no scaling in JRE-HiDPI mode
      UIUtil.DEF_SYSTEM_FONT_SIZE = font.getSize() / scale; // derive actual system base font size
      if (isScaleVerbose) {
        log.info(String.format("DEF_SYSTEM_FONT_SIZE: %.2f", UIUtil.DEF_SYSTEM_FONT_SIZE));
      }
    }
    else if (!SystemInfo.isJetBrainsJvm) {
      // With Oracle JDK: derive scale from X server DPI, do not change DEF_SYSTEM_FONT_SIZE
      float size = UIUtil.DEF_SYSTEM_FONT_SIZE * getScreenScale();
      font = font.deriveFont(size);
      if (isScaleVerbose) {
        log.info(String.format("(Not-JB JRE) reset font size: %.2f", size));
      }
    }
  }
  else if (SystemInfo.isWindows) {
    //noinspection HardCodedStringLiteral
    @SuppressWarnings("SpellCheckingInspection") Font winFont = (Font)Toolkit.getDefaultToolkit().getDesktopProperty("win.messagebox.font");
    if (winFont != null) {
      font = winFont; // comes scaled
      if (isScaleVerbose) {
        log.info(String.format("Windows sys font: %s, %d", winFont.getFontName(), winFont.getSize()));
      }
    }
  }
  Pair<String, Integer> result = Pair.create(font.getName(), font.getSize());
  if (isScaleVerbose) {
    log.info(String.format("ourSystemFontData: %s, %d", result.first, result.second));
  }
  return result;
}