CLIFramework
CLIFramework copied to clipboard
Logging error with '%' : Warning fprintf too few arguments
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.
I think the fix is ok. Please send a pr