From 4364ebfa18586686f4230de2fb350777f05e42fa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 23 Dec 2016 13:11:54 +0300 Subject: juick-console: logging --- .../src/main/java/com/juick/console/ConsoleApp.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'juick-console/src/main') 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 { -- cgit v1.2.3