nickvanw / ircx

Basic callback-driven Go IRC bot
Apache License 2.0
37 stars 13 forks source link

Remove go-kit, use `logrus` #33

Open nickvanw opened 5 years ago

nickvanw commented 5 years ago

This builds on top of #32, which should be reviewed first.

go-kit is a big dependency that is not needed. This uses logrus instead which is much more purpose-built and self contained.

Right now, the default will be a logger that only discards data - while it'd be cool for the default to be something else, I don't think that libraries should do anything by default, and should be self contained. This does that, and allows for just a single line to override that if necessary by using SetLogger.

cc @mvdan Closes #31

nickvanw commented 5 years ago

In an ideal world, we would have a standard logging interface that all libraries can interoperate with. In reality, a consensus hasn't been reached on that yet, so you have to pick a simple enough interface that works for you, and expose it in your API. For example, for your limited needs, I'd recommend:

I completely agree with this, and I frequently go back and forth on how to handle this in a meaningful way. I personally find it unfortunate that every package needs to define it's own logging interface - in a world where a package can use many different dependencies and libraries (as is common), I've witnessed multiple adapters being written, which is too bad. On the other hand, you're totally right that this couples the library with a single logging library, which is potentially even more annoying.

While the logger does technically take an interface, logrus' FieldLogger is large enough that it's unlikely that any other package could import it, and doing so requires importing logrus anyway, because of some of the method arguments in the interface require logrus-specific types.

Ultimately, I wrote this library for my purposes, and you're really the only other active person with an opinion. That makes me think it's probably not worth doing what's most convenient for me, though it is tempting :)

mvdan commented 5 years ago

That makes me think it's probably not worth doing what's most convenient for me, though it is tempting :)

I know a couple of open source projects use my irc bot built on top of this, so there definitely are some users :) Perhaps dozens of us!

Ultimately up to you. go-kit was painful IMO, logrus is small in comparison. So I'm fine even if you merge this as-is, and blame the lack of a canonical log interface for it.