Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Write To A Log File From A Neovim Lua Plugin

This is the function I'm using while working on Neovim plugins.

Code

local log_to_file = function(message, path)
    local log_file_path = path 
    local log_file = io.open(log_file_path, "a")
    io.output(log_file)
    io.write(message.."\n")
    io.close(log_file)
end