Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MonologBridge] Add monolog processors adding route and command info#28330

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@trakos
Copy link
Contributor

@trakostrakos commentedAug 31, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRsymfony/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.

@lyrixx
Copy link
Member

I like it but I have some comments

  1. The RouteProcessor does not work well. The "RouteData" should be unset on "kernel.finish_request".
  2. The RoutePRocessor might be merged with thehttps://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Monolog/Processor/WebProcessor.php ?

@trakos
Copy link
ContributorAuthor

trakos commentedSep 3, 2018
edited
Loading

  1. Yes, you're right, I didn't consider subrequests. I've updated it - I've made it so that it includes an array of (sub)requests, kind of like a stacktrace:
[    {        "controller": "App\\Controller\\SomeController::number",        "route": "index",        "route_params": []    },    {        "controller": "App\\Controller\\SomeController::other",        "route": "other",        "route_params": {            "page": "235"        }    }]

The last one is the current one. It pops last entry during "kernel.finish_request". What do you think?

  1. I can combine them if you prefer. There's some things to consider:

    • Users won't be aware that update will make their log messages longer
    • WebProcessor is an extend of monolog's WebProcessor, I think it's supposed to add the same information to the log
    • There's probably some users that enable WebProcessor just to have IP logged and won't be happy about lengthier messages

@lyrixx What do you think?

@trakostrakosforce-pushed themonolog_processors_command_and_route branch 2 times, most recently frome6dee3f to803dc25CompareSeptember 3, 2018 20:44
@fabpot
Copy link
Member

@lyrixx Can you review the latest version of this PR? Thank you.

Copy link
Member

@lyrixxlyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It seems better. 👏
I left some comments.
Thanks for your work.

@trakos
Copy link
ContributorAuthor

Thanks for your feedback@lyrixx . I've updated the changes.

In RouteProcessor I've decided to usespl_object_id instead ofSplObjectStorage, there's less code that way. Is that OK?

@nicolas-grekas
Copy link
Member

meanwhile, ProcessorInterface has been removed from the bridge and added to Monolog directly inSeldaek/monolog#1204
If we don't want to bump the minimum version of Monolog, we should register the new classes for autoconfiguration, seesymfony/monolog-bundle#285

@trakos
Copy link
ContributorAuthor

Would you like me to create PR in symfony/monolog-bundle registering this classes, or should I wait till some decision is made?

@nicolas-grekas
Copy link
Member

Let's first finish this one :)

Copy link
Member

@lyrixxlyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM except one tiny comment

@trakostrakosforce-pushed themonolog_processors_command_and_route branch 3 times, most recently fromac92e84 tod331569CompareNovember 13, 2018 18:47
@trakos
Copy link
ContributorAuthor

@lyrixx thanks, I've made the change. I've also removed extending ProcessorInterface, since it's no longer there. It should be ready now.

@lyrixx
Copy link
Member

lyrixx commentedMar 16, 2019
edited
Loading

let's merge this one (except for native English, I can not tell)

@fabpotfabpotforce-pushed themonolog_processors_command_and_route branch frome17ae9a to669f6b2CompareMarch 17, 2019 07:08
@fabpot
Copy link
Member

Thank you@trakos.

@fabpotfabpot merged commit669f6b2 intosymfony:masterMar 17, 2019
fabpot added a commit that referenced this pull requestMar 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#10244This 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
wouterj added a commit to symfony/symfony-docs that referenced this pull requestApr 9, 2019
This PR was merged into the master branch.Discussion----------Add documentation on new monolog processorsDocumentation supportingsymfony/symfony#28330Commits-------3421c6c [MonologBridge] Add documentation on new processors
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@lyrixxlyrixxlyrixx approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

5 participants

@trakos@lyrixx@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp