CLIFramework icon indicating copy to clipboard operation
CLIFramework copied to clipboard

Logging error with '%' : Warning fprintf too few arguments

Open sherbrow opened this issue 6 years ago • 1 comments

Hello,

We get from time to time the warning

Warning: fprintf(): Too few arguments in /path/to/project/vendor/corneltek/cliframework/src/Logger.php on line 183

Because the message getting logged contains %, in our case, an URL encoded provided by the service we're calling.

A quick fix is to escape % :

fprintf(STDERR, str_replace('%', '%%', $this->formatter->format($msg , $style)) . PHP_EOL);

https://github.com/c9s/CLIFramework/blob/5d7c4703390e80326938cbdef7de499bca2a0143/src/Logger.php#L188

I'm not sure where to point a fix, if the formatter should be involved or not, although I'm convinced the fprintf without additional arguments should escape %.

Thank you for your help.

sherbrow avatar Sep 01 '19 09:09 sherbrow

I think the fix is ok. Please send a pr

c9s avatar Sep 02 '19 04:09 c9s