diff options
author | 2016-12-23 13:11:54 +0300 | |
---|---|---|
committer | 2016-12-23 13:11:54 +0300 | |
commit | 4364ebfa18586686f4230de2fb350777f05e42fa (patch) | |
tree | 61a8fc02a9bac25d4561b4431da0df9bd450632c /juick-console/src/main/java/com/juick | |
parent | b3506329d5c3e0aca8bfc8e469826e0774e488cc (diff) |
juick-console: logging
Diffstat (limited to 'juick-console/src/main/java/com/juick')
-rw-r--r-- | juick-console/src/main/java/com/juick/console/ConsoleApp.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/juick-console/src/main/java/com/juick/console/ConsoleApp.java b/juick-console/src/main/java/com/juick/console/ConsoleApp.java index 22a26609..bfa3eae3 100644 --- a/juick-console/src/main/java/com/juick/console/ConsoleApp.java +++ b/juick-console/src/main/java/com/juick/console/ConsoleApp.java @@ -10,6 +10,8 @@ import org.jline.reader.LineReaderBuilder; import org.jline.reader.UserInterruptException; import org.jline.terminal.Terminal; import org.jline.terminal.TerminalBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.core.env.Environment; @@ -22,6 +24,9 @@ import java.lang.reflect.InvocationTargetException; * Created by vitalyster on 19.12.2016. */ public class ConsoleApp { + + private static final Logger logger = LoggerFactory.getLogger(ConsoleApp.class); + @Inject JuickProtocol juickProtocol; @Inject @@ -49,19 +54,20 @@ public class ConsoleApp { while (true) { try { String input = reader.readLine(prompt, null, null); + if (input == null) { + logger.error("invalid terminal"); + break; + } ProtocolReply reply = juickProtocol.getReply(user, input); out.println(reply.getResult()); out.flush(); } catch (UserInterruptException e) { - + logger.debug("user interrupt"); } catch (EndOfFileException e) { + logger.debug("app exit"); break; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); + } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + logger.warn("protocol exception", e); } } } else { |