A plain log shows what was printed, not how it unfolded. The macOS script can store timing too and replay the session like a video.
Start a recording. Everything you do runs in a new shell until you type exit:
script -r demo.rec
# work as usual, then
exit
Play it back in the terminal, with the same pauses as when it was recorded:
script -p demo.rec
Add -d to skip the pauses and see it all at once. You can also record a single command, which is how I’d capture a flaky install step:
script -q -r install.rec ./install.sh
script -p -d install.rec
The file is a binary format, not a text log, so open it with script -p rather than cat.
This is the BSD version on the Mac. On Linux, util-linux script uses -T or --log-timing with scriptreplay instead, so the commands don’t carry over. And remember what a recording holds: everything you typed and saw, including passwords that were echoed and tokens printed on screen. Treat the file like a log with secrets in it.
Further reading: script man page (macOS)