consulo.logging.Logger Java Examples
The following examples show how to use
consulo.logging.Logger.
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 |
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: NamedConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@Override public final JComponent createComponent() { if (myOptionsComponent == null){ myOptionsComponent = createOptionsPanel(); final JComponent component = createTopRightComponent(myNameField); if (component == null) { myTopRightPanel.setVisible(false); } else { myTopRightPanel.add(component, BorderLayout.CENTER); } } if (myOptionsComponent != null) { myOptionsPanel.add(myOptionsComponent, BorderLayout.CENTER); } else { Logger.getInstance(getClass()).error("Options component is null for "+getClass()); } updateName(); return myWholePanel; }
Example #3
Source File: StartupActionScriptManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void execute(Logger logger) throws IOException { if (mySource == null) { return; } if (!mySource.exists()) { logger.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this); } else if (!FileUtilRt.delete(mySource)) { logger.error("Action " + this + " failed."); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MessageFormat.format("<html>Cannot delete {0}<br>Please, check your access rights on folder <br>{1}", mySource.getAbsolutePath(), mySource.getAbsolutePath()), "Installing Plugin", JOptionPane.ERROR_MESSAGE); } }
Example #4
Source File: CertificateUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static X509Certificate loadX509Certificate(@Nonnull String path) { try { InputStream stream = new FileInputStream(path); try { return (X509Certificate)ourFactory.generateCertificate(stream); } finally { stream.close(); } } catch (Exception e) { Logger.getInstance(CertificateUtil.class).error("Can't add certificate for path: " + path, e); return null; } }
Example #5
Source File: SystemShortcuts.java From consulo with Apache License 2.0 | 6 votes |
private static @Nonnull String getDescription(@Nonnull AWTKeyStroke systemHotkey) { if (ourShkClass == null) ourShkClass = ReflectionUtil.forName("java.awt.desktop.SystemHotkey"); if (ourShkClass == null) return ourUnknownSysAction; if (ourMethodGetDescription == null) ourMethodGetDescription = ReflectionUtil.getMethod(ourShkClass, "getDescription"); String result = null; try { result = (String)ourMethodGetDescription.invoke(systemHotkey); } catch (Throwable e) { Logger.getInstance(SystemShortcuts.class).error(e); } return result == null ? ourUnknownSysAction : result; }
Example #6
Source File: AppUIUtil.java From consulo with Apache License 2.0 | 6 votes |
private static void registerFont(@NonNls String name) { try { URL url = AppUIUtil.class.getResource(name); if (url == null) { throw new IOException("Resource missing: " + name); } InputStream is = url.openStream(); try { Font font = Font.createFont(Font.TRUETYPE_FONT, is); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font); } finally { is.close(); } } catch (Exception e) { Logger.getInstance(AppUIUtil.class).error("Cannot register font: " + name, e); } }
Example #7
Source File: StartupUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void loadSystemLibraries(final Logger log) { // load JNA in own temp directory - to avoid collisions and work around no-exec /tmp File ideTempDir = new File(ContainerPathManager.get().getTempPath()); if (!(ideTempDir.mkdirs() || ideTempDir.exists())) { throw new RuntimeException("Unable to create temp directory '" + ideTempDir + "'"); } if (System.getProperty("jna.tmpdir") == null) { System.setProperty("jna.tmpdir", ideTempDir.getPath()); } if (System.getProperty("jna.nosys") == null) { System.setProperty("jna.nosys", "true"); // prefer bundled JNA dispatcher lib } JnaLoader.load(log); if (SystemInfo.isWin2kOrNewer) { IdeaWin32.isAvailable(); // logging is done there } if (SystemInfo.isWindows) { // WinP should not unpack .dll files into parent directory System.setProperty("winp.folder.preferred", ideTempDir.getPath()); } }
Example #8
Source File: StartupUtil.java From consulo with Apache License 2.0 | 6 votes |
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 #9
Source File: StartupActionScriptManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void execute(final Logger logger) throws IOException { if (!mySource.exists()) { logger.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this); } else if (!canCreateFile(myDestination)) { JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MessageFormat .format("<html>Cannot unzip {0}<br>to<br>{1}<br>Please, check your access rights on folder <br>{2}", mySource.getAbsolutePath(), myDestination.getAbsolutePath(), myDestination), "Installing Plugin", JOptionPane.ERROR_MESSAGE); } else { try { ZipUtil.extract(mySource, myDestination, myFilenameFilter); } catch (Exception ex) { logger.error(ex); JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MessageFormat .format("<html>Failed to extract ZIP file {0}<br>to<br>{1}<br>You may need to re-download the plugin you tried to install.", mySource.getAbsolutePath(), myDestination.getAbsolutePath()), "Installing Plugin", JOptionPane.ERROR_MESSAGE); } } }
Example #10
Source File: Promises.java From consulo with Apache License 2.0 | 6 votes |
public static boolean errorIfNotMessage(Logger logger, Throwable e) { if (e instanceof InternalPromiseUtil.MessageError) { boolean log = ((InternalPromiseUtil.MessageError)e).log; // TODO handle unit test? //if (log == ThreeState.YES || (log == ThreeState.UNSURE && ApplicationManager.getApplication().isUnitTestMode())) { // logger.error(e); // return true; //} } else if (!(e instanceof ControlFlowException) && !(e instanceof CancellationException)) { logger.error(e); return true; } return false; }
Example #11
Source File: MappedBufferWrapper.java From consulo with Apache License 2.0 | 6 votes |
@Override public void flush() { MappedByteBuffer buffer = myBuffer; if (buffer != null && isDirty()) { for (int i = 0; i < MAX_FORCE_ATTEMPTS; i++) { try { buffer.force(); myDirty = false; break; } catch (Throwable e) { Logger.getInstance(MappedBufferWrapper.class).info(e); TimeoutUtil.sleep(10); } } } }
Example #12
Source File: ZipHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private EntryInfo getOrCreate(@Nonnull String entryName, Map<String, EntryInfo> map, @Nonnull ArchiveFile zip) { EntryInfo info = map.get(entryName); if (info == null) { ArchiveEntry entry = zip.getEntry(entryName + "/"); if (entry != null) { return getOrCreate(entry, map, zip); } Pair<String, String> path = splitPath(entryName); EntryInfo parentInfo = getOrCreate(path.first, map, zip); info = store(map, parentInfo, path.second, true, DEFAULT_LENGTH, DEFAULT_TIMESTAMP, entryName); } if (!info.isDirectory) { Logger.getInstance(getClass()).info(zip.getName() + ": " + entryName + " should be a directory"); info = store(map, info.parent, info.shortName, true, info.length, info.timestamp, entryName); } return info; }
Example #13
Source File: DesktopImportantFolderLocker.java From consulo with Apache License 2.0 | 6 votes |
@Override public void dispose() { log("enter: dispose()"); BuiltInServer server = myServer; if (server == null) return; try { Disposer.dispose(server); } finally { try { underLocks(() -> { FileUtil.delete(new File(myConfigPath, PORT_FILE)); FileUtil.delete(new File(mySystemPath, PORT_FILE)); FileUtil.delete(new File(mySystemPath, TOKEN_FILE)); return null; }); } catch (Exception e) { Logger.getInstance(DesktopImportantFolderLocker.class).warn(e); } } }
Example #14
Source File: LogMessageEx.java From consulo with Apache License 2.0 | 5 votes |
public static void error(@Nonnull Logger logger, @Nonnull String message, @Nonnull Throwable cause, @Nonnull String... attachmentText) { StringBuilder detailsBuffer = new StringBuilder(); for (String detail : attachmentText) { detailsBuffer.append(detail).append(","); } if (attachmentText.length > 0 && detailsBuffer.length() > 0) { detailsBuffer.setLength(detailsBuffer.length() - 1); } Attachment attachment = detailsBuffer.length() > 0 ? AttachmentFactory.get().create("current-context.txt", detailsBuffer.toString()) : null; logger.error(createEvent(message, ExceptionUtil.getThrowableText(cause), null, null, attachment)); }
Example #15
Source File: StubSerializationHelper.java From consulo with Apache License 2.0 | 5 votes |
void serialize(@Nonnull Stub rootStub, @Nonnull OutputStream stream) throws IOException { BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(); FileLocalStringEnumerator storage = new FileLocalStringEnumerator(true); IntEnumerator selializerIdLocalEnumerator = new IntEnumerator(); StubOutputStream stubOutputStream = new StubOutputStream(out, storage); boolean doDefaultSerialization = true; if (rootStub instanceof PsiFileStubImpl) { final PsiFileStub[] roots = ((PsiFileStubImpl<?>)rootStub).getStubRoots(); if (roots.length == 0) { Logger.getInstance(getClass()).error("Incorrect stub files count during serialization:" + rootStub + "," + rootStub.getStubType()); } else { doDefaultSerialization = false; DataInputOutputUtil.writeINT(stubOutputStream, roots.length); for (PsiFileStub root : roots) { serializeRoot(stubOutputStream, root, storage, selializerIdLocalEnumerator); } } } if (doDefaultSerialization) { DataInputOutputUtil.writeINT(stubOutputStream, 1); serializeRoot(stubOutputStream, rootStub, storage, selializerIdLocalEnumerator); } DataOutputStream resultStream = new DataOutputStream(stream); selializerIdLocalEnumerator.dump(resultStream); storage.write(resultStream); resultStream.write(out.getInternalBuffer(), 0, out.size()); }
Example #16
Source File: IndicesRegistrationResult.java From consulo with Apache License 2.0 | 5 votes |
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 #17
Source File: IndexInfrastructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public final T call() throws Exception { long started = System.nanoTime(); try { prepare(); runParallelNestedInitializationTasks(); return finish(); } finally { Logger.getInstance(getClass()).info("Initialization done: " + (System.nanoTime() - started) / 1000000); } }
Example #18
Source File: DesktopContainerStartup.java From consulo with Apache License 2.0 | 5 votes |
private static void start(StatCollector stat, Runnable appInitalizeMark, String[] args) { try { StartupActionScriptManager.executeActionScript(); } catch (IOException e) { Logger.getInstance(DesktopContainerStartup.class).error(e); StartupUtil.showMessage("Plugin Installation Error", e); return; } // desktop locker use netty. it will throw error due log4j2 initialize // see io.netty.channel.MultithreadEventLoopGroup.logger // it will override logger, which is active only if app exists // FIXME [VISTALL] see feac1737-76bf-4952-b770-d3f8d1978e59 // InternalLoggerFactory.setDefaultFactory(ApplicationInternalLoggerFactory.INSTANCE); StartupUtil.prepareAndStart(args, DesktopImportantFolderLocker::new, (newConfigFolder, commandLineArgs) -> { AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame(), false); AppUIUtil.registerBundledFonts(); ApplicationStarter app = new DesktopApplicationStarter(DesktopApplicationPostStarter.class, commandLineArgs); SwingUtilities.invokeLater(() -> { PluginManager.installExceptionHandler(); app.run(stat, appInitalizeMark, newConfigFolder); }); }); }
Example #19
Source File: GeneralTestEventsProcessor.java From consulo with Apache License 2.0 | 5 votes |
public static void logProblem(final Logger log, final String msg, boolean throwError, final String testFrameworkName) { final String text = getTFrameworkPrefix(testFrameworkName) + msg; if (throwError) { log.error(text); } else { log.warn(text); } }
Example #20
Source File: RegExHelpPopup.java From consulo with Apache License 2.0 | 5 votes |
@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 #21
Source File: URLUtil.java From consulo with Apache License 2.0 | 5 votes |
public static URL internProtocol(@Nonnull URL url) { try { final String protocol = url.getProtocol(); if ("file".equals(protocol) || "jar".equals(protocol)) { return new URL(protocol.intern(), url.getHost(), url.getPort(), url.getFile()); } return url; } catch (MalformedURLException e) { Logger.getInstance(URLUtil.class).error(e); return null; } }
Example #22
Source File: PathUtilRt.java From consulo with Apache License 2.0 | 5 votes |
private static Charset fsCharset() { if (!SystemInfoRt.isWindows && !SystemInfoRt.isMac) { String property = System.getProperty("sun.jnu.encoding"); if (property != null) { try { return Charset.forName(property); } catch (Exception e) { Logger.getInstance(PathUtilRt.class).warn("unknown JNU charset: " + property, e); } } } return null; }
Example #23
Source File: ExceptionUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String getUserStackTrace(@Nonnull Throwable aThrowable, Logger logger) { final String result = getThrowableText(aThrowable, "com.intellij."); if (!result.contains("\n\tat")) { // no stack frames found logger.error(aThrowable); } return result; }
Example #24
Source File: DropAnErrorWithAttachmentsAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent e) { final boolean multipleAttachments = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0; Attachment[] attachments; if (multipleAttachments) { attachments = new Attachment[]{new Attachment("first.txt", "first content"), new Attachment("second.txt", "second content")}; } else { attachments = new Attachment[]{new Attachment("attachment.txt", "content")}; } Logger.getInstance("test (with attachments)").error(LogMessageEx.createEvent("test", "test details", attachments)); }
Example #25
Source File: DropAnErrorAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent e) { /* Project p = (Project)e.getDataContext().getData(DataConstants.PROJECT); final StatusBar bar = WindowManager.getInstance().getStatusBar(p); bar.fireNotificationPopup(new JLabel("<html><body><br><b> Notifier </b><br><br></body></html>")); */ ArtifactManager.getInstance(e.getProject()); Logger.getInstance("test").error("Test"); }
Example #26
Source File: ProcessOutput.java From consulo with Apache License 2.0 | 5 votes |
/** * 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 #27
Source File: Log4J2Logger.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setLevel(@Nonnull LoggerLevel level) throws IllegalAccessException { Class callerClass = ReflectionUtil.findCallerClass(1); if (callerClass == null) { throw new IllegalAccessException("There not caller class"); } PluginDescriptor plugin = PluginManager.getPlugin(callerClass); if (plugin == null || !PluginIds.isPlatformPlugin(plugin.getPluginId())) { throw new IllegalAccessException("Plugin is not platform: " + plugin); } org.apache.logging.log4j.core.Logger logger = myLoggerContext.getLogger(myLogger.getName()); Level newLevel; switch (level) { case INFO: newLevel = Level.INFO; break; case WARNING: newLevel = Level.WARN; break; case ERROR: newLevel = Level.ERROR; break; case DEBUG: newLevel = Level.DEBUG; break; case TRACE: newLevel = Level.TRACE; break; default: throw new IllegalArgumentException("Wrong level: " + level); } logger.setLevel(newLevel); }
Example #28
Source File: StartupUtil.java From consulo with Apache License 2.0 | 5 votes |
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 #29
Source File: StartupUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void prepareAndStart(String[] args, BiFunction<String, String, ImportantFolderLocker> lockFactory, PairConsumer<Boolean, CommandLineArgs> appStarter) { boolean newConfigFolder; CommandLineArgs commandLineArgs = CommandLineArgs.parse(args); if (commandLineArgs.isShowHelp()) { CommandLineArgs.printUsage(); System.exit(ExitCodes.USAGE_INFO); } if (commandLineArgs.isShowVersion()) { ApplicationInfo infoEx = ApplicationInfo.getInstance(); System.out.println(infoEx.getFullApplicationName()); System.exit(ExitCodes.VERSION_INFO); } AppUIUtil.updateFrameClass(); newConfigFolder = !new File(ContainerPathManager.get().getConfigPath()).exists(); ActivationResult result = lockSystemFolders(lockFactory, args); if (result == ActivationResult.ACTIVATED) { System.exit(0); } else if (result != ActivationResult.STARTED) { System.exit(ExitCodes.INSTANCE_CHECK_FAILED); } Logger log = Logger.getInstance(StartupUtil.class); logStartupInfo(log); loadSystemLibraries(log); fixProcessEnvironment(log); appStarter.consume(newConfigFolder, commandLineArgs); }
Example #30
Source File: LightTreeUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String toFilteredString(@Nonnull LighterAST tree, @Nonnull LighterASTNode node, @Nullable TokenSet skipTypes) { int length = node.getEndOffset() - node.getStartOffset(); if (length < 0) { length = 0; Logger.getInstance(LightTreeUtil.class).error("tree=" + tree + " node=" + node); } StringBuilder buffer = new StringBuilder(length); toBuffer(tree, node, buffer, skipTypes); return buffer.toString(); }