-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#2148 - Incorrect use of ts, quotes, escape in log call #18864
Conversation
(Standard links)
|
@seamuslee001 do you agree on the escape comments? |
We write all sorts to the log, and any presentation of the log needs the usual care (e.g. htmlspecialchars). I don't think the escaping was adding anything useful so I agree with @demeritcowboy My preference would be to use I like that it tells you something useful now, though 👍 |
Thanks. I think the way to do variable representation would be to use the PSR-3 placeholders, and then whichever log implementation you're using can json_encode, var_dump, emojify, or whatever. Right now the default log implementation in civi doesn't recognize them, but it could. Or it's not hard to write an extension with a different log implementation - hook_civicrm_container: |
You've prompted me to think more about the variable placeholders and I've updated the PR to use them. With the current implementation of CRM_Core_Error_Log it ends up looking a little weird when the variables are strings, but is still readable and you can match up the values, and I think it is the right way to do it. There are a couple of Civi::log calls in civi that already use them, e.g. Civi/Angular/Manager.php. This way another implementation can then decide what it wants to do with the variable values, or the core default one can be improved. Lab ticket time. (https://lab.civicrm.org/dev/core/-/issues/2161) |
Yep, it's annoying that Civi log ignores placeholders. I gave up on it ages ago and usually just append json encoded data to the message and ignore the parameters bit. I'm big fan of JSON output because it's easily copy and pasteable, so if you're debugging and need to re-run something you can easily get the values back into some code. Anyhoo. I waffle. |
I think if the combined brain power of @demeritcowboy & @artfulrobot agree here then it's good to merge |
Oh @demeritcowboy I remember why I don't use CiviCRM, as stated above, ignores PSR log placeholders. This is annoying but could be fixed, but it would need to consider two things: (1) is the value of the placeholder stringable? e.g. numbers, strings are OK, but what if the value is an array/object? PSR suggests that the values should be as raw as possible to preserve information; so then I'd suggest something like However Drupal 7 (don't know about 8+) gives you a world of pain if its placeholders (via I think it's helpful to
|
Cool. Yes I was thinking most implementations may or may not want to treat strings differently, including core's. Have added your comment in the lab ticket. |
Overview
https://lab.civicrm.org/dev/core/-/issues/2148
$dbName
instead of the value because the string uses single quotes.Before
Well, the main functional problem is that it doesn't tell you what field it's talking about. It just literally calls it
$dbName
.After
Better
Technical Details
Comments