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

Added loglevel attribute to the phpcs task. #1134

Merged
merged 8 commits into from
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion classes/phing/tasks/ext/PhpCSTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
class PhpCSTask extends Task
{
use LogLevelAware;

/**
* A php source code filename or directory
*
Expand All @@ -50,6 +52,7 @@ class PhpCSTask extends Task
public function __construct()
{
$this->cmd = new Commandline();
$this->logLevelName = 'info';
parent::__construct();
}

Expand Down Expand Up @@ -123,7 +126,7 @@ public function main()
$exe->setTaskName($this->getTaskName());
$exe->setExecutable($this->bin);
$exe->setCheckreturn($this->checkreturn);
$exe->setLevel('info');
$exe->setLevel($this->logLevelName);
$exe->setExecutable($toExecute->getExecutable());
$exe->createArg()->setLine(implode(' ', $toExecute->getArguments()));
$exe->main();
Expand Down
6 changes: 6 additions & 0 deletions classes/phing/tasks/system/element/LogLevelAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
trait LogLevelAware
{
protected $logLevel = Project::MSG_VERBOSE;
protected $logLevelName = 'verbose';

/**
* Set level of log messages generated (default = verbose)
Expand All @@ -36,18 +37,23 @@ public function setLevel($level): void
switch ($level) {
case 'error':
$this->logLevel = Project::MSG_ERR;
$this->logLevelName = 'error';
break;
case 'warning':
$this->logLevel = Project::MSG_WARN;
$this->logLevelName = 'warning';
break;
case 'info':
$this->logLevel = Project::MSG_INFO;
$this->logLevelName = 'info';
break;
case 'verbose':
$this->logLevel = Project::MSG_VERBOSE;
$this->logLevelName = 'verbose';
break;
case 'debug':
$this->logLevel = Project::MSG_DEBUG;
$this->logLevelName = 'debug';
break;
default:
throw new BuildException(
Expand Down
15 changes: 15 additions & 0 deletions docs/guide/en/source/appendixes/optionaltasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8752,6 +8752,21 @@ Note that you can omit both startpoint and track attributes in this case
<entry><literal>false</literal></entry>
<entry>No</entry>
</row>
<row>
<entry><literal>level</literal></entry>
<entry><literal role="type">String</literal></entry>
<entry>Set the log level of generated messages.
Change this to <literal>verbose</literal>,
if you only want output in verbose mode for example.
Valid log levels are one of
<literal>debug</literal>,
<literal>info</literal>,
<literal>verbose</literal>,
<literal>warning</literal> or
<literal>error</literal></entry>
<entry><literal>info</literal></entry>
<entry>No</entry>
</row>
</tbody>
</tgroup>
</table>
Expand Down
11 changes: 11 additions & 0 deletions etc/phing-grammar.rng
Original file line number Diff line number Diff line change
Expand Up @@ -5043,6 +5043,17 @@
<data type="boolean"/>
</attribute>
</optional>
<optional>
<attribute name="level" a:defaultValue="info">
<choice>
<value>error</value>
<value>warning</value>
<value>info</value>
<value>verbose</value>
<value>debug</value>
</choice>
</attribute>
</optional>
</interleave>
</element>
</define>
Expand Down
2 changes: 1 addition & 1 deletion test/etc/tasks/ext/phpcs/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
</target>

<target name="testPhpCs">
<phpcs bin="../../../../../bin/phpcs" file="../../../../../classes/phing/dispatch" checkreturn="false" ignoreAnnotations="true" />
<phpcs bin="../../../../../bin/phpcs" file="../../../../../classes/phing/dispatch" level="debug" checkreturn="false" ignoreAnnotations="true" />
</target>
</project>