Search in sources :

Example 1 with LspLogger

use of org.eclipse.n4js.xtext.ide.server.util.LspLogger in project n4js by eclipse.

the class LspServer method setupAndRunWithSystemIO.

private void setupAndRunWithSystemIO(XLanguageServerImpl languageServer, Builder<LanguageClient> lsBuilder) {
    N4jscConsole.println(LSP_SYNC_MESSAGE + " on stdio ...");
    N4jscConsole.setSuppress(true);
    LspLogger lspLogger = languageServer.getLspLogger();
    Appender lspLoggerAppender = redirectLog4jToLspLogger(lspLogger);
    Appender serverIncidentAppender = copyLog4jErrorsToServerIncidentLogger(languageServer.getServerIncidentLogger());
    PrintStream oldStdOut = System.out;
    PrintStream oldStdErr = System.err;
    try (PrintStream loggingStream = new LoggingPrintStream(lspLogger)) {
        System.setOut(loggingStream);
        System.setErr(loggingStream);
        run(languageServer, lsBuilder, System.in, oldStdOut);
    } finally {
        System.setErr(oldStdErr);
        System.setOut(oldStdOut);
        Logger.getRootLogger().removeAppender(serverIncidentAppender);
        Logger.getRootLogger().removeAppender(lspLoggerAppender);
    }
}
Also used : Appender(org.apache.log4j.Appender) WriterAppender(org.apache.log4j.WriterAppender) PrintStream(java.io.PrintStream) LspLogger(org.eclipse.n4js.xtext.ide.server.util.LspLogger)

Aggregations

PrintStream (java.io.PrintStream)1 Appender (org.apache.log4j.Appender)1 WriterAppender (org.apache.log4j.WriterAppender)1 LspLogger (org.eclipse.n4js.xtext.ide.server.util.LspLogger)1