Skip to content

Add documentation on new monolog processors #10244

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

Merged

Conversation

trakos
Copy link
Contributor

@trakos trakos commented Aug 31, 2018

Documentation supporting symfony/symfony#28330

@xabbuh xabbuh added the Waiting Code Merge Docs for features pending to be merged label Sep 3, 2018
symfony-splitter pushed a commit to symfony/monolog-bridge that referenced this pull request Mar 17, 2019
…d command info (trakos)

This PR was squashed before being merged into the 4.3-dev branch (closes #28330).

Discussion
----------

[MonologBridge] Add monolog processors adding route and command info

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs#10244

This PR adds two simple processors that add context to every log entry.

RouteProcessor adds routing information:
`app.INFO: Some log text {"someContext":"ctx"} {"route":{"controller":"App\\Controller\\SomeController::number","route":"index","route_params":[]}`

ConsoleCommandProcessors adds current command information:
`app.INFO: Some log text {"someContext":"ctx"} {"command":{"name":"app:some-command","arguments":{"command":"app:some-command","some-argument":10}}}`

For ConsoleCommandProcessor I've decided against including command options by default, because there's a lot of default ones:
`"options":{"help":false,"quiet":false,"verbose":false,"version":false,"ansi":false,"no-ansi":false,"no-interaction":false,"env":"dev","no-debug":false}`. This behavior can be changed with a constructor argument.

Commits
-------

669f6b2726 [MonologBridge] Add monolog processors adding route and command info
fabpot added a commit to symfony/symfony that referenced this pull request Mar 17, 2019
…d command info (trakos)

This PR was squashed before being merged into the 4.3-dev branch (closes #28330).

Discussion
----------

[MonologBridge] Add monolog processors adding route and command info

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        | symfony/symfony-docs#10244

This PR adds two simple processors that add context to every log entry.

RouteProcessor adds routing information:
`app.INFO: Some log text {"someContext":"ctx"} {"route":{"controller":"App\\Controller\\SomeController::number","route":"index","route_params":[]}`

ConsoleCommandProcessors adds current command information:
`app.INFO: Some log text {"someContext":"ctx"} {"command":{"name":"app:some-command","arguments":{"command":"app:some-command","some-argument":10}}}`

For ConsoleCommandProcessor I've decided against including command options by default, because there's a lot of default ones:
`"options":{"help":false,"quiet":false,"verbose":false,"version":false,"ansi":false,"no-ansi":false,"no-interaction":false,"env":"dev","no-debug":false}`. This behavior can be changed with a constructor argument.

Commits
-------

669f6b2 [MonologBridge] Add monolog processors adding route and command info
@dmaicher
Copy link
Contributor

dmaicher commented Apr 6, 2019

Code PR was merged 😊

@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Apr 6, 2019
@javiereguiluz javiereguiluz changed the title [WCM] Add documentation on new monolog processors Add documentation on new monolog processors Apr 6, 2019
@javiereguiluz
Copy link
Member

The related code was finally merged a few days ago, so this one is ready to merge.

@wouterj if you agree, you could solve the conflict while merging. Also, we must add a versionadded:: 4.3 telling that RouteProcessor and ConsoleCommandProcessors are new.

@OskarStark OskarStark added the ⭐️ EU-FOSSA Hackathon https://symfony.com/blog/the-symfony-and-api-platform-hackathon-is-coming label Apr 6, 2019
@trakos
Copy link
Contributor Author

trakos commented Apr 6, 2019

I've added an issue some time ago: #11185 because I'm not sure how I should fix the conflict. There used to be mentions of WebProcessor and TokenProcessor on this page, but now those mentions seems to have been removed. So now I'm not sure if the built-in processors should be mentioned on this page.

@dbrumann
Copy link
Contributor

dbrumann commented Apr 6, 2019

I think my PR #11328 could help with solving the conflict. I introduced the section for the existing processors outside of the tip. Hopefully you can just add the remaining ones when that PR gets merged.

wouterj added a commit that referenced this pull request Apr 7, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

Adds documentation for monolog processors.

Adds both a short description for existing processors as well as a note for the newly added TokenProcessor added in 3.4. I tried not to interfere with #10244 as this introduces documentation for more processors added in 4.3, so that PR hopefully can build on this one.

Replaces #8156

EUFOSSA

Commits
-------

67f8c2c Adds documentation for monolog processors.
@wouterj
Copy link
Member

wouterj commented Apr 7, 2019

Fyi, @dbrumann's PR is just merged, so you should be able to rebase this PR and extend the list he added to the docs. Please then also add a versionadded directive telling these processors were introduced in Symfony 4.3.

@trakos trakos force-pushed the monolog_processors_command_and_route branch from df1b10d to 3421c6c Compare April 9, 2019 09:50
@trakos
Copy link
Contributor Author

trakos commented Apr 9, 2019

@wouterj thanks, I've updated this PR and added the versionadded directive

@wouterj
Copy link
Member

wouterj commented Apr 9, 2019

I like it, thank you Piotr for your quick responses!

@wouterj wouterj merged commit 3421c6c into symfony:master Apr 9, 2019
wouterj added a commit that referenced this pull request Apr 9, 2019
This PR was merged into the master branch.

Discussion
----------

Add documentation on new monolog processors

Documentation supporting symfony/symfony#28330

Commits
-------

3421c6c [MonologBridge] Add documentation on new processors
@greg0ire
Copy link
Contributor

@trakos hi! Sorry for digging this up. Do you recall why reset was implemented the way it is? If you have a rabbitMQ consumer and it uses the ServiceResetterProcessor, reset will be called after each message, making ConsoleCommandProcessor ineffective quite fast. Thanks in advance.

@trakos
Copy link
Contributor Author

trakos commented Dec 13, 2021

@greg0ire wait, what is ServiceResetterProcessor? :) I don't recall a class like that in Symfony. Not sure why rabbitMQ consumer would reset log processor?

I don't think you're supposed to be resetting the processor from the outside. I mean, my initial MR did not include public reset method, but a reviewer suggested making it implement ResetInterface to make it clearer. However, it should work fine without resetting from the outside.

@greg0ire
Copy link
Contributor

greg0ire commented Dec 13, 2021

@trakos sorry, ServiceResetterProcessor is a swarrot processor (nothing to do with Monolog): https://github.com/swarrot/swarrot/blob/master/src/Swarrot/Processor/ServicesResetter/ServicesResetterProcessor.php

It's quite handy when you have fingers_crossed set up, because that way you don't run out of memory trying to store all log messages since the consumer started, you discard them after each message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ EU-FOSSA Hackathon https://symfony.com/blog/the-symfony-and-api-platform-hackathon-is-coming Logger Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants