-
Notifications
You must be signed in to change notification settings - Fork 45
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
formatter_glue fails when no unnamed arguments #130
Comments
Revision: it's extra, yes, but perhaps we create a format string from the names/values of the arguments. For instance, one of: log_formatter(formatter_glue)
log_info(quux="a", b=pi)
# INFO [2023-11-19 16:16:23] a 3.14159265358979
##### or
log_info(quux="a", b=pi)
# INFO [2023-11-19 16:16:41] quux=a b=3.14159265358979 While one could play with this type of mechanism for hours, I suggest going anywhere beyond this is too much: the only reason to do any of this is to prevent an empty log entry; if the user wants more control (semi-delimited, quoted strings, whatever) then they should format it the right way the first time. |
More so ... if one does go this one step of auto-adding a simple format string for |
Thanks a ton for this report, and I agree that it can be frustrating when this happens 😞 But I'm hesitant to make such overrides in how > str(glue::glue("foo", NULL, quux="a", b=pi))
'glue' chr(0) My suggestion is to check what Please see an example implementation at #147 |
I don't see quite how adding a warning is much better than adding a safeguard, but it's your call. Thanks! |
fix #130 throw warning with inputs when glue returns nothing to log
Needed to drop this PR as per above: |
If Perhaps it would be useful to know the use-case that In the end, though, I believe that my recommended change is "safe": for those already using |
These are very good points, @r2evans, thanks! I've opened a ticket (see above) and looking forward to hearing from the Now that it's done, we can update the dev version again at any time, run the reverse dependency checks again, and warn users about the change in |
@daroczig made appropriate changes on |
Awesome, thank you so much, @atalv 🙌 🙇 |
Occasionally I forget (i.e., when interactive) to set
log_formatter(formatter_json)
. When this happens, any log messages that use named arguments will be blank. For instance,where the initial intent was to have this:
I'm fine with the fact that part of the reason is that I forgot the formatter, but it would be nice if
formatter_glue
did not drop named arguments. I suggest the names can be dropped, and pasted together (with a space). Something like:Edit ... as I'm thinking about this, the purpose and layout of
glue
is rather simple, where unnamed objects are strings to format, and named objects are variables to use for substitution ... so I think thepaste
-ing above should only be done when none of...
are unnamed ... or perhaps just assume the first or first character or similar.Bottom line, having it completely drop the message is perhaps not good. Thoughts?
The text was updated successfully, but these errors were encountered: