This package allows you to easily test the Laravel Log functionality.
We currently support the following Laravel versions.
Version | Supported |
---|---|
8.x | ✅ |
9.x | ✅ |
You can install the package via composer:
composer require frankperez87/laravel-log-fake
use frankperez87\LaravelLogFake\Facades\Log;
Log::fake();
logger()->withContext([
'yay' => 'it works',
]);
logger()->info('this is a info log');
# You can use the helpers via the Facade
Log::assertContext(function ($context) {
return $context == ['yay' => 'it works'];
});
Log::assertLogged(function ($log) {
return
$log['level'] == 'emergency' &&
$log['message'] == 'this is a emergency log';
});
# You can also use the helper instead
logger()->assertContext(function ($context) {
return $context == ['yay' => 'it works'];
});
logger()->assertLogged(function ($log) {
return
$log['level'] == 'emergency' &&
$log['message'] == 'this is a emergency log';
});
composer test
Please see CHANGELOG for more information on what has changed recently.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.