How to statefully capture LSP log messages and show in buffer?

I am curious how I might go about capturing log lines from an LSP, and when i want, open a buffer with those logs.

I am able to easily print these lines with

vim.lsp.handlers["window/logMessage"] = function(_, _, log)
  if log.type == 4 then

But I am not adept at buffer manipulation, or how to store these lines without accumulating memory.

If anyone could help get me started, or point me to an existing article/tutorial/docs, I would appreciate it!