Laev.Log (laev v0.1.40)

Copy Markdown View Source

Keep the logger off the screen, and keep it from taking the app down with it.

Two things go wrong when a terminal app logs to its own terminal. The small one is a stray line scrolling a picker out from under the cursor. The large one is what happened on a Mac left open overnight: a TLS alert was reported when the laptop's connections died, the handler went to format it, and the modules formatting needs — io_lib_pretty, Inspect.Opts, neither resident at boot — could not be loaded, because they live in the unpacked payload the standalone binary runs from and the system had cleaned that up hours before. The formatter crashed, the crash was logged, and that log crashed the same way. Several thousand times, over the whole screen.

So nothing writes to the terminal. What there is to say goes to ~/.laev/laev.log, through a handler written here rather than one of OTP's: a handler is a module with log/2, and ours formats with no lazily-loaded machinery, cannot ask for a module that isn't there, and treats its own failure as nothing worth mentioning. The formatting modules are pulled into memory at boot anyway, for everything else that might reach for them.

Summary

Functions

Silence the terminal, take the log to a file, preload the formatters.

Where the log is, for anyone asking what went wrong.

Functions

install()

Silence the terminal, take the log to a file, preload the formatters.

path()

Where the log is, for anyone asking what went wrong.