karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/3] karaf git commit: [KARAF-5079] Log:tail does not print messages steadily
Date Mon, 03 Apr 2017 08:39:07 GMT
Repository: karaf
Updated Branches:
  refs/heads/master 37827b5f5 -> fa3828bba


[KARAF-5079] Log:tail does not print messages steadily

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4f18c5b9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4f18c5b9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4f18c5b9

Branch: refs/heads/master
Commit: 4f18c5b96c8e561e2a4eb7500917884a7d352864
Parents: 37827b5
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Mon Apr 3 10:01:31 2017 +0200
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Mon Apr 3 10:01:31 2017 +0200

----------------------------------------------------------------------
 log/src/main/java/org/apache/karaf/log/command/LogTail.java    | 6 +++++-
 .../main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4f18c5b9/log/src/main/java/org/apache/karaf/log/command/LogTail.java
----------------------------------------------------------------------
diff --git a/log/src/main/java/org/apache/karaf/log/command/LogTail.java b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
index 6e3fe23..516a3c3 100644
--- a/log/src/main/java/org/apache/karaf/log/command/LogTail.java
+++ b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
@@ -41,7 +41,7 @@ public class LogTail extends DisplayLog {
     @Reference
     LogService logService;
 
-    private ExecutorService executorService = Executors.newSingleThreadExecutor();
+    private ExecutorService executorService = Executors.newFixedThreadPool(2);
 
     @Override
     public Object execute() throws Exception {
@@ -100,6 +100,7 @@ public class LogTail extends DisplayLog {
             for (PaxLoggingEvent event : le) {
                 printEvent(out, event, minLevel);
             }
+            out.flush();
             // Tail
             final BlockingQueue<PaxLoggingEvent> queue = new LinkedBlockingQueue<PaxLoggingEvent>();
             PaxAppender appender = new PaxAppender() {
@@ -111,6 +112,9 @@ public class LogTail extends DisplayLog {
                 logService.addAppender(appender);
                 while (doDisplay) {
                     printEvent(out, queue.take(), minLevel);
+                    if (queue.isEmpty()) {
+                        out.flush();
+                    }
                 }
             } catch (InterruptedException e) {
                 // Ignore

http://git-wip-us.apache.org/repos/asf/karaf/blob/4f18c5b9/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
index 07a63f7..364bafe 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
@@ -98,8 +98,8 @@ public class ShellFactoryImpl implements Factory<Command> {
                 final Subject subject = ShellImpl.this.session != null ? ShellImpl.this.session
                         .getAttribute(KarafJaasAuthenticator.SUBJECT_ATTRIBUTE_KEY) : null;
                 String encoding = getEncoding(env);
-                final PrintStream pout = out instanceof PrintStream ? (PrintStream) out :
new PrintStream(out, false, encoding);
-                final PrintStream perr = err instanceof PrintStream ? (PrintStream) err :
out == err ? pout : new PrintStream(err, false, encoding);
+                final PrintStream pout = out instanceof PrintStream ? (PrintStream) out :
new PrintStream(out, true, encoding);
+                final PrintStream perr = err instanceof PrintStream ? (PrintStream) err :
out == err ? pout : new PrintStream(err, true, encoding);
                 terminal = new SshTerminal(env, in, pout);
                 shell = sessionFactory.create(in,
                         pout, perr, terminal, encoding, this::destroy);


Mime
View raw message