Write logs to a file when the --log option is provided#4113
Open
lacatoire wants to merge 1 commit intophpDocumentor:masterfrom
Open
Write logs to a file when the --log option is provided#4113lacatoire wants to merge 1 commit intophpDocumentor:masterfrom
lacatoire wants to merge 1 commit intophpDocumentor:masterfrom
Conversation
75ef2ae to
f5e9e7d
Compare
The option was declared in Application::getDefaultInputDefinition but never consumed, so a user passing --log foo.log saw the option in --help yet no file was ever written (see phpDocumentor#1872). Wire a LogConfigurator event listener that, on ConsoleEvents::COMMAND, pushes a Monolog StreamHandler for the requested path. The handler level follows the console verbosity (notice, -v info, -vv/-vvv debug) and --quiet disables file logging entirely, matching the intent captured in Transform.php. Paths are canonicalised through Monolog Utils so a relative and an absolute form dedup to the same handler on nested ConsoleEvents::COMMAND dispatches, and the same dedup is applied to the ConsoleLogHandler to avoid duplicate console output. Covered by new unit tests for missing / empty / quiet cases, the verbosity-to-level mapping, the nested-dispatch and relative-path dedups, and distinct log files producing two handlers. A functional test runs phpdoc with --log and asserts the target receives a stable log line. Fixes phpDocumentor#1872
f5e9e7d to
598d18b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire up the
--logCLI option so it actually creates the requested log file.The option was declared in
Application::getDefaultInputDefinition()but never consumed: no Monolog handler was attached, so the file was never created (see #1872).This change:
Monolog\Handler\StreamHandlerfor the--logpath when the option is provided-v, info at-vv, debug at-vvv)-q/--quietis passed, matching the intent captured inTransform.phpThe v2
<logging>XML node only accepts<level>and never had a<paths>child; the v3 config schema has nologgingnode at all. Fixing that XML path is out of scope for this PR.Fixes #1872.