Skip to content
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

Requirements checker now logs to stderr #679

Merged
merged 3 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

# From 3.16.0 to 3.17.0

- The requirements checker now logs its output to `stderr` instead of `stdout` per default. Set `BOX_REQUIREMENTS_CHECKER_LOG_TO_STDOUT=1` to restore the old behaviour.


# From 3.1.3 to 3.2.0

- Changes to the `Php` compactor:
Expand Down
10 changes: 10 additions & 0 deletions doc/requirement-checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ $ BOX_REQUIREMENT_CHECKER=0 php box.phar
```


## Logging to stdout

Since version 3.17.0, box logs the requirements checker output to `stderr` per default (see: [#678](https://github.com/box-project/box/issues/678)).
The requirements checker can be configured to output to `stdout` instead by setting `BOX_REQUIREMENTS_CHECKER_LOG_TO_STDOUT=1`:

```
$ BOX_REQUIREMENTS_CHECKER_LOG_TO_STDOUT=1 php box.phar
```


<br />
<hr />

Expand Down
3 changes: 3 additions & 0 deletions requirement-checker/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<php>
<!-- The width is matching the Travis one to avoid any issues with the CI -->
<env name="COLUMNS" value="80" />

<!-- required for output buffering -->
<env name="BOX_REQUIREMENTS_CHECKER_LOG_TO_STDOUT" value="1" />
</php>

<testsuites>
Expand Down
7 changes: 6 additions & 1 deletion requirement-checker/src/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public function printv(string $message, int $verbosity, ?string $style = null):
$this->supportColors ? $this->styles['reset'] : ''
);

echo $message;
if (getenv('BOX_REQUIREMENTS_CHECKER_LOG_TO_STDOUT') === '1') {
// use echo/print to support output buffering
echo $message;
} else {
fwrite(STDERR, $message);
}
}
}