samuelirwin/logger

This is a wrapper package to create standard logging information for better debugging

dev-main 2023-12-09 21:43 UTC

This package is auto-updated.

Last update: 2024-09-09 23:41:53 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Installation

You can install the package via composer:

composer require samuelirwin/logger

Usage

Logger::record(object $class, string $method, string $logType, string $summary, array $details = [])

Example

You can use $this in a class to get the class object

class Foo {
    public function bar()
    {
        Logger::record(
            $this, // class object
            'bar', // name of the method
            'error', // log types; $allowedLogTypes = ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'];
            'Summary of error message', 
            [
                // inside here can be anything you want to log
                'detail-1' => 1,
                'detail-2' => 'new details',
                'details-3' => 'more details'
            ]);
    }
}

Result Output

{
    "context": "ClassName::methodName",
    "location": "/path/to/file",
    "details": {
        "id": 1,
        "code": 444,
        "message": "exception message"
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email samuelirwin1992@gmail.com instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.