mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.27k stars 242 forks source link

Logger output breaks text. #418

Closed Niall7459 closed 5 years ago

Niall7459 commented 5 years ago

Screenshot 2019-05-28 at 13 19 31

I expected this. As the logger logs it breaks the text. I refresh the table every second using Screen#refresh() is not an option (low-bandwith systems and delay whilst re drawing)

I'm using SLF4J. Preferably need to be able to do something on runtime to fix this. Possibly disabling the loggers. Any ideas?

Regards.

Niall7459 commented 5 years ago

Similar to #137

avl42 commented 5 years ago

Well, logging frameworks like slf4j usually are highly configurable, so it should be possible to disable the console loggers and let logging lines go to a log file.

If you really need to see the lines on console, then it is common to have Ctrl-L refresh the screen: users will see the scrambled screen as in your screenshot, and they can then do a manual refresh to see the output of your tool again.

mabe02 commented 5 years ago

The Screen layer uses a buffer to remember what was written earlier, which is why when you write directly to the underlying terminal things get weird. You could attach a custom appender to the logging backend that initiates a full refresh after something was written to the logger, but turning off logging or logging to standard error and redirecting it to a file is probably your best options.

Niall7459 commented 5 years ago

That's probably what I will do. Mainly a question on if Lanterna had this feature built in or not, I will close this. Regards