PHP code example of frankperez87 / laravel-log-fake

1. Go to this page and download the library: Download frankperez87/laravel-log-fake library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

frankperez87 / laravel-log-fake example snippets


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';
});