Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log-level logdebug repeatedly clears the terminal during output #673

Open
jwatts-maybe opened this issue Nov 29, 2024 · 2 comments
Open

Comments

@jwatts-maybe
Copy link

jwatts-maybe commented Nov 29, 2024

Running any Essence model (including an empty one) with the -log-level flag set to logdebug (or logdebugverbose) repeatedly clears the terminal during output.

(Cannot currently confirm this on a platform other than Linux)

From a quick bit of digging, the issue seems to be from this part of the definition of runLoggerPipeIO in Prelude.hs being tripped incorrectly by the logging output:

when ("[" `isPrefixOf` txt) $ do
    liftIO clearScreen
    liftIO (setCursorPosition 0 0)

This contains the only reference to clearScreen, and watching the terminal output, every time the first character post-clear is indeed a [ (e.g. in [addTrueConstraints]).

@ozgurakgun
Copy link
Collaborator

I considered this a feature not a bug actually :)

In my terminal clearing the screen means scrolling to the top and I can always scroll back to see the previous outputs. Is this not the case for you? I can see how it would be annoying if it's not!

@jwatts-maybe
Copy link
Author

Having checked a little more, it seems I oversimplified. I had this issue recorded from a few weeks back and when quickly looking today assumed that was the root cause. I definitely am not getting the full output, and it does seem to separate on the boundaries used by clear.

My test example is just from one of the tutorials. I've attached screenshots with side-by-side comparisons of the full output as captured by piping to a file (> stdout.txt) vs what I see in the terminal. The images are for a clean run and a run with cached models (both are scrolled to the top of any visible output, and I also checked my terminal is set to store enough lines of output that that shouldn't have any impact).

Full run:
Full Run
Cached run:
Short Run

Notably, in the full run case I get portions of correct output, mixed with missing passages (this was the behaviour I originally observed and didn't bother to try and replicate earlier today, a mistake with hindsight).

Looking at https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 and the man page for clear, my current guess is that the ANSI code [2J which keeps appearing in the output clears what is currently visible on the screen (compared to the [3J command which also clears the scrollback buffer). I can find some historical questions which seem to indicate this wasn't always the behaviour (mostly people complaining that it only scrolls down, ironically), though it seems surprising that it would have changed.

It seems like recompiling without the three lines I originally mentioned does remove the issue, so if this is all they were intended for (i.e. I won't break anything else) I can just leave my build like that for now, so this isn't a major issue. If I get chance I might sort a different distro in a VM to make sure this isn't specific to Konsole (if anyone else is already running something other than KDE, feel free).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants