-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Macro formatting #315
Comments
Yes. There's always a tradeoff between clarity and convenience 😉 I am not an expert on Since replacing I have previously considered rewriting the slog macros as procedural macros to fix a couple (minor) bugs and improve clarity. I think this would allow us to work around the ambiguity, but I'm not sure. |
We possibly could support both, and while technically possibly breaking, in practice it would just work, I think. |
Yeah after diving in it was tricky coming up with a set of symbols that format properly but also allow expressing all the things slog does right now. I've been using this modified set of macros in my projects -- I can't remember exactly what I did but I think I got rid of the string interpolation and tags, since the kvs are more important to me than interpolation
|
Yes. Dropping support for
Thank you for this code! This should help working around the ambiguity with I still think rewriting the macros as proc-macros is the right way to add this feature. The current macro implementation seems unclear and is prone to bugs (see #248). Switching would also improve clarity and give better error messages. Either way we end up implementing it, I appreciate the code. |
FWIW I ended up writing a new rust formatter at https://github.com/andrewbaxter/genemichaels which formats macros decently and is a sufficient solution for me, so I'll close this. |
I think rust generally gives up with formatting macros, but it seems like some function-style macros will be automatically formatted.
log!("message", "a"="b", "c"="something else")
will actually be wrapped and spaced prettily (not sure what my formatter is, I'm using the rust analyzer vs code plugin).=>
seems to block the formatter.It's easy to work around (just copy the macros and replace
=>
with=
), and it would be a breaking change if introduced to the library, but I thought I'd just bring it up for thought.Totally unrelated, but I came here after looking at tracing and I'd much prefer slog. Tracing has tons of undocumented magic, and (AFAICT) the use of globals/thread locals to do the magic then leads to issues like using spans with async code, etc. The fact that you pass loggers around explicitly is a huge selling point for me.
Anyways, I really appreciate the project!
The text was updated successfully, but these errors were encountered: