frankperez87/laravel-log-fake

Enables you to test the Laravel Logger.

0.2.2 2022-07-22 04:02 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package allows you to easily test the Laravel Log functionality.

Supported Versions

We currently support the following Laravel versions.

Installation

You can install the package via composer:

composer require frankperez87/laravel-log-fake

Usage

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

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.