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: 2025-07-10 01:51:51 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

Installation

You can install the package via composer:

composer require samuelirwin/logger

Usage

Parameters Type Description
$class object Required
$method string Required
$logType string Required
$summary string Required
$details array Optional
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"
    }
}
Allowed Log Types
emergency
alert
error
warning
notice
info
debug

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.