Problem/Motivation
The Extended Logger allows storing not only the plain key-value scalar values, but also structured logs with nested structures.
But Drupal placeholders support only plain keys and plain values; even dots are not allowed there!
Fortunately, Drupal's LogMessageParser also supports PSR3 style messages, which use curly brackets and allow using dots in the placeholder text!
But, unfortunately, this will not work out of the box, because Drupal's LogMessageParser doesn't support nested values.
Proposed resolution
The good news is that we can extend Drupal's default LogMessageParser by adding support for dot-represented paths using the NestedArray utility.
And we can even extend this by supporting JSONPath expressions for more complex queries - this will not follow the PSR3 style placeholders already, because symbols like $ are not allowed there, but still we will have the backwards compatibility.
Also, would be good to provide an option for backward compatibility for the default Drupal logger and other logger types, by copying the nested values as keys of the plain $context array - this should make them work well with the default Drupal logger.
Issue fork extended_logger-3537997
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
murzComment #5
murzImplemented, now we can use messages with tokens like this:
And the final message in the log entry will be:
My message: My value 1 and My value 2 and that's itAlso, introduced a submodule "extended_logger_fallback" that replaces the Drupal Core's service
logger.log_message_parserto a custom one, that extends the base service with JSONPath placeholders. With it, this will work even for Drupal Core loggers like dblog and syslog!Comment #6
murz