Skip to content

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

License

Notifications You must be signed in to change notification settings

frankperez87/laravel-log-fake

Repository files navigation

Laravel Log Fake

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.

Version Supported
8.x
9.x

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.

About

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

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages