Tastyep/structlog.nvim

question: integration into a plugin

aserowy opened this issue · 2 comments

Hi,

i want to integrate your wonderful logging tool as optional dependency into aserowy/tmux.nvim. The point is, i have a REALLY light integration for logging and could define a new channel at https://github.com/aserowy/tmux.nvim/tree/main/lua/tmux/log. Thus, the user must configure it proactively to use your logging implementation.
But it would be cool, to just check if your plugin is present and if so, register the channel automatically. Do you have any idea how i can check if your plugin exists (and is loaded) to register all log calls against it?

Kind regards
Alexander

Hello,

Thank you for your interest and kind words.
I think you could achieve that by checking package.loaded:
if package.loaded["structlog"] then ... end

Now, I'm not sure if I understand correctly what you are trying to achieve. Personally, I would replace your logging implementation with structlog and extend it to your needs by defining new sinks (what you called channel).

If needed, I made a luarocks package.

EDIT: Another idea, you could accept a custom logger when configuring your plugin and fallback to your own implementation (as long as interfaces match)

ty for the heads up. This is exactly what i need.

To clarify: I do not want to introduce a breaking change to extend logging and force a new plugin (which functionality is not strictly needed for all users) but want to support your (way better and specialized) plugin in an additive way. Thus, somebody (like me in my own config) can introduce your plugin and tmux.nvim will use it if installed.

Kind regards