[GH-ISSUE #889] Formatter Syntax (Documentation Not Available) #349

Closed
opened 2026-03-04 02:14:20 +03:00 by kerem · 3 comments
Owner

Originally created by @lloy0076 on GitHub (Nov 23, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/889

There's no obvious cheat sheet for what substitutions one can make for the Formatters (I'm specifically thinking of the "LineFormatter". I've tried to follow the code backwards via inheritance and can see that it extends the NormalizeFormatter but its not clear to me how or where the substitutions are made.

If it were, I'd have proposed a Pull Request for such documentation.

  1. It's probably somewhere really obvious - but if it is can someone point me to it (and possibly make it more obvious)?
  2. If it's really obvious, as in the code where the substitutions are made is obvious, could someone point me to the code so I can read/understand and make a Pull Request to help out?

If it's not really obvious, how might we better document what one can put into the format string for the LineFormatter and possibly other relevant loggers?

I'm using the latest version of Monolog from composer (composer update monolog/monolog) and looking in the latest MASTER on this GitHub.

(I'd add this to the documentation label but I'm not sure how to do that either :()

Originally created by @lloy0076 on GitHub (Nov 23, 2016). Original GitHub issue: https://github.com/Seldaek/monolog/issues/889 There's no obvious cheat sheet for what substitutions one can make for the Formatters (I'm specifically thinking of the "LineFormatter". I've tried to follow the code backwards via inheritance and can see that it extends the NormalizeFormatter but its not clear to me how or where the substitutions are made. If it were, I'd have proposed a Pull Request for such documentation. 1. It's probably somewhere really obvious - but if it is can someone point me to it (and possibly make it more obvious)? 2. If it's really obvious, as in the code where the substitutions are made is obvious, could someone point me to the code so I can read/understand and make a Pull Request to help out? If it's not really obvious, how might we better document what one can put into the format string for the LineFormatter and possibly other relevant loggers? I'm using the latest version of Monolog from composer (composer update monolog/monolog) and looking in the latest MASTER on this GitHub. (I'd add this to the documentation label but I'm not sure how to do that either :()
kerem 2026-03-04 02:14:20 +03:00
Author
Owner

@Seldaek commented on GitHub (Nov 25, 2016):

You mean the substitutions in the line format like %foo% in https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php#L24 right?

It's done in format() https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php#L71-L107 and basically any field of the $record array is usable for substitution.. If it's a complex data type it's stringified using the NormalizerFormatter code, but the details of that shouldn't really matter to most users. What would be good is to document all fields of $record, and then extra and context are also available via %extra.foo% for example to access subkey foo. If you'd like to work on a PR for that that'd be great, but not sure where to fit this best.

<!-- gh-comment-id:263031989 --> @Seldaek commented on GitHub (Nov 25, 2016): You mean the substitutions in the line format like %foo% in https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php#L24 right? It's done in format() https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php#L71-L107 and basically any field of the $record array is usable for substitution.. If it's a complex data type it's stringified using the NormalizerFormatter code, but the details of that shouldn't really matter to most users. What would be good is to document all fields of $record, and then extra and context are also available via `%extra.foo%` for example to access subkey foo. If you'd like to work on a PR for that that'd be great, but not sure where to fit this best.
Author
Owner

@lloy0076 commented on GitHub (Nov 26, 2016):

Ah, now that you've pointed it out I can see where the substitutes happen - I'd be happy to work on a PR which I'll place "somewhere" with the acknowledgment that I mightn't get it in the "right" place at first :)

<!-- gh-comment-id:263034672 --> @lloy0076 commented on GitHub (Nov 26, 2016): Ah, now that you've pointed it out I can see where the substitutes happen - I'd be happy to work on a PR which I'll place "somewhere" with the acknowledgment that I mightn't get it in the "right" place at first :)
Author
Owner

@Seldaek commented on GitHub (Nov 26, 2016):

No worries, moving text is a lot easier than writing it ;)

<!-- gh-comment-id:263035163 --> @Seldaek commented on GitHub (Nov 26, 2016): No worries, moving text is a lot easier than writing it ;)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#349
No description provided.