Learn more about the Inspector Disguise...
The Kluzo\Disguise
class is what actually you are interacting with when you
work with the library.
It is a static proxy that wraps the Inspector object, and hosts
the list of Inspector Tricks. There is a class alias created for
Kluzo\Disguise
called kluzo
and this is what you are going to be using
most of the time:
kluzo::log('discounts', $discountValue, $originalPrice);
kluzo::json('logs', $payload);
...
The static proxy will make it easier to call Kluzo from wherever within your code.
You can get the current Inspector by calling Kluzo\Disguise::getInspector()
:
kluzo::getInspector()->closeCase(); // ends up Kluzo's work prematurely
It will not happen often (if any), but you can swap your Inspector objects using
Kluzo\Disguise::setInspector()
:
use App\MyOwnInspector;
kluzo::setInspector( new MyOwnInspector );
There is an Inspector class declared by default, Kluzo\Inspector\ChiefInspector
.
It comes with few pockets, such as "Request", "Session", "Server" and "Files".
It goes without saying that that Kluzo should stay silened on live production
environments. To do this, use kluzo::mute()
(this is actually
Kluzo\Disguise::mute()
). What this does is it will replace the current
inspector with an "Imposter" (Kluzo\Inspector\ImposterInspector
) that
ignores your commands and at the end of the script will not produce a report.
if (!app()->environment('local', 'staging'))
{
kluzo::mute();
}
To get the list of Inspector Tricks, you can call kluzo::getTricks()
(that is actually Kluzo\Disguise::getTricks()
).
Here is the same stupid example as used in the Tricks documentation:
kluzo::getTricks()->learnTrick('fool', function($pocketName, ...$things)
{
$things[] = 'You Fool!';
return $this->log($pocketName, ...$things);
});