Feature #2740

screens hardcopy function could be used to retrieve a log in case a component crashes but logging is not enabled

Added by L. Schillingmann almost 7 years ago. Updated almost 7 years ago.

Status:ResolvedStart date:10/05/2017
Priority:NormalDue date:
Assignee:L. Schillingmann% Done:

100%

Category:-
Target version:-

Description

The following idea came to my mind when investigating how to retrieve screen buffers in a script:
screen -S "some.screenname" -X -p0 hardcopy -h /tmp/some.screen.dump

After the component ends, probably this could be called to dump the current screen session
screen -S "$STY" -X -p0 hardcopy -h /tmp/some.screen.dump

Note that -h includes the contents of the scrollback buffer

History

#1 Updated by R. Haschke almost 7 years ago

  • Assignee set to L. Schillingmann

Looks like an interesting feature. But if the component crashed, the screen would been gone already too, wouldn't it?
If we place the command directly when starting the component, the log file would be created in any case. Or can we somehow know that the command crashed?

#2 Updated by L. Schillingmann almost 7 years ago

Hmm, placing the function after the call to component would catch it. E.g. here before sleep 0.01: source:vdemo_base.sh#L159
Component is executed inside screen. So the screen should close only after cmd is completed (or killed).

#3 Updated by R. Haschke almost 7 years ago

So the screen should close only after cmd is completed (or killed).

My questions is, how you decide whether to keep the screen dump or not. Or would you simply keep it in any case (which would be fine too).

#4 Updated by L. Schillingmann almost 7 years ago

I see, got it. Yes, I would keep it in any case, since the performance impact should be minimal and there is no risk of excess disk usage.
In theory one could use the exit code but I doubt that this would be reliable since we do not know what will be executed in component after something crashed.

#5 Updated by R. Haschke almost 7 years ago

OK. Then go for it. Please use the same file name as for logs. Only do the dump, when logging is disabled ;-)

#6 Updated by L. Schillingmann almost 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Seems to work. Note that screen hardcopy is linewrapped, contains initial newlines, etc. Added trimming and a comment to avoid confusion with regular logfiles.

#7 Updated by R. Haschke almost 7 years ago

Thanks a lot!

Also available in: Atom PDF