jwiegley/alert

`alert-log-messages` and packages.

Opened this issue · 0 comments

I was poking at some old configs and I saw alert-log-messages which claims that, when non-nil will cause alerts to go to Alerts. Huh, I use alerts sometimes, and have had this setting for years and I've never seen an *Alerts* buffer. So I did some digging.

It looks like this *Alerts* is a legacy behavior implemented in alert-legacy-log-notify which only runs when log4e isn't installed, which can't happen (I think) if you install alert as a package because log4e always gets pulled in as a dependency.

I managed to do a little big of hacking to my elpa directory and get it to work, and then in the course of writing up this ticket I managed to figure out how to get log4e to work.

I'm not sure what the "right" thing to do here is:

  • I think it'd be reasonable to unwind log4e. I personally don't use it for anything else, and (maybe this is a generational thing) but I also haven't really used log4<x> before and I don't find it super obvious, and I don't really feel like I need a special (optional) logging package that I don't otherwise use, for a really simple alert package (that I do use.)
  • To be honest, I think i'd be fine if, when alert-log-messages is non-nil, we could just call (message (format "[alert:%s] %s" (format-time "%02H:%02M") alert-msg)) and call it good? I don't know that the extra buffer is what I want, and the name of the variable (to me) implies the messages buffer?
  • If we really like log4e, I think it'd be nice to either (both?) document the way to use it (change the variable's docstring, etc.) and also maybe wrap alert--log-open-log (and friends) in something that seems less "internal" (the --) or is more clearly named for manipulation. I certainly had to poke around a lot to find this.
  • Also having spent a lot of time in this code, it seems like we're ending up calling the log4e:deflogger macro potentially for every message. This is probably fine and works as intended, but I think left to my own devices I'd have a variable or struct in the package that would store the log4e logger and functions? I mean, reasonably speaking I think storing a function pointer/message function for this logging (which could be log4e or just message seems reasonable to me? I'm not suggesting you leave me to my devices though.

Thoughts? I'm willing to do a little work to sand off this rough corner, but wouldn't want to begin making changes without some kind of initial agreement. 😄