UserFrosting
UserFrosting copied to clipboard
[FEATURE REQUEST] Make Debug::debug second parameter accept all kind of variables
Right now, at least on my setup, if you pass a variable that is not an array to the second parameter of a Debug::debug
expression, the execution is halted with an error:
var1 = 'Hey there';
Debug::debug('Value of variable:', var1);
functionAA();
Argument 2 passed to Monolog\Logger::debug() must be of the type array, string given, called in /app/app/system/Facade.php on line 239
That will not print the debug and the functionAA is not executed either because the Debug failed.
Would it be difficult to accept all kind of variables and just dump them to the log? The current way I need to check every time if what I want to print is an array. I've ended putting [ ] around everything just to be sure.
Maybe we can do something like:
if (variable_passed is type array) {
dump variable_passed;
} else {
dump [variable_passed];
}
Editing to reflect that you don't get error message in the log, but I'm getting it on the screen.
Looks like a limitation on Monolog side. We would need to encapsulate the debug method so we convert string to array manually.
FYI, I usually do, with whatever kind of var I have :
Debug::debug(print_r($foo, true));
(or use XDebug 😁 )
Debug facade is not available in UF5 anymore.