This Package helps you in laravel application to log all desired activity for each request from request entry point to generate response at a single snapshot.

Overview

Laravel Scenario Logger

This Package helps you in laravel application to log all desired activity for each request from request entry point to generate response at a single snapshot.

Table of Contents
  1. Installation
  2. Usage
  3. Contact
  4. Acknowledgements
  5. Contributing
  6. Todo List
  7. Suggested Feature

Installation

  1. run composer command
    composer require escherchia/laravel-scenario-logger
  1. In order to handle logging on exceptions add this lines of code to Your default exception handler(usually App\Exception\Handler):
    use Escherchia\LaravelScenarioLogger\Logger\ScenarioLogger;
    public function register()
    {
            $this->reportable(function (Throwable $e) {
                ScenarioLogger::logForService('log_exception', $e);
                ScenarioLogger::finish();
            });
    }
        ...
  1. run publish command on your shell if your want to access package configuration file in your application:
      php artisan vendor:publish
  1. run migrations to ensure you have proper tables in database :
      php artisan migrate

please select LaravelScenarioLoggerServiceProvider in order to publish package providers

Usage

After proper installation of this package into your application, all request will be logged using default storage driver which is database built-in storage driver. Default storage driver is defined in package configuration file.

in order to log scenarios, logger service must be active. this feature could be find on configuration file:

...
   'is_active' => true,
...

storage

alternative logging storage driver could be defined by defining that in configuration file like this:

...
   'default_storage_driver' => Path\TO\YourStorageDriver,
...

YourStorageDriver class must implement Escherchia\LaravelScenarioLogger\StorageDrivers\StorageDriverInterface

database driver connection

if you decide to use built-in database driver to log your scenarios art persistent layer, you can specify which database driver should be used.

...
   'storage_drivers' => [
       'database' => [
           'connection' => 'your-connection-name'
       ]   
   ]
...

logger services

for each scenario each part of logging is handled by a dedicated module. you can remove this feature from process of scenario logger by commenting this module on list of active services:

...
  'service_configuration' => [
     'log_user' => [
        'active' => true,
        'class' => LogUser::class
    ],
    'log_response' => [
        'active' => true,
        'class' => LogResponse::class,
        'disable-store-content' => false,
    ],
    'log_request' => [
        'active' => true,
        'class' => LogRequest::class,
    ],
    'log_exception' => [
        'active' => true,
        'class' => LogException::class,
    ],
    'log_manual_trace' => [
        'active' => true,
        'class' => LogManualTrace::class,
    ],
    'log_model_changes' => [
        'active' => true,
        'class' => LogModelChanges::class,
        'models' => [
            // model goes here
        ],
    ],
  ]
...

excluded routes

you can introduce some route uris as excluded routes to log like this:

...
  'excluded-routes' => [
     'some/route/uri'
  ]
...

Contributing

if you want to contribute in this project please follow this instruction.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a PR on this repository
  6. wait to accept and merge the PR

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Mehrdad Mahdian: Gmail

Project Link: laraval-scenario-logger

Todo

  • descriptive comment for config items
  • update dependencies to proper versions in composer.json
  • support logger in console mode

Suggested Features

  • log viewer utility
  • console commands scenario logs
  • ability to store logs in queue
You might also like...
Laravel Larex lets you translate your whole Laravel application from a single CSV file.
Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex Translate Laravel Apps from a CSV File Laravel Larex lets you translate your whole Laravel application from a single CSV file. You can i

Generate robust laravel athorization without writing a single line of code.

Implement robust laravel authorization logic without writing a single line of code This package helps you to quickly create strong policy authorizatio

Filament-spatie-laravel-activitylog - View your activity logs inside of Filament. ⚑️

View your activity logs inside of Filament. This package provides a Filament resource that shows you all of the activity logs created using the spatie

A Laravel package helps you add a complete real-time messaging system to your new / existing application with only one command.
A Laravel package helps you add a complete real-time messaging system to your new / existing application with only one command.

A Laravel package helps you add a complete real-time messaging system to your new / existing application with only one command.

Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Smeify is a Stable Automated Solution for Airtime and Data businesses in Nigeria, this package helps you integrate smeify easily into your laravel application.

Configurable activity logger for filament.

Activity logger for filament Configurable activity logger for filament. Powered by spatie/laravel-activitylog Features You can choose what you want to

A simple package that helps PHP developers to generate the QR code signature as per Zakat authority (ZATCA) requirements of Saudi Arabia.

A PHP package that implements the e-invoice QR code signature requirements as designed by the Zakat authority of Saudi Arabia. How to install? compose

This package provides a Logs page that allows you to view your Laravel log files in a simple UI
This package provides a Logs page that allows you to view your Laravel log files in a simple UI

A simplistics log viewer for your Filament apps. This package provides a Logs page that allows you to view your Laravel log files in a simple UI. Inst

GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn
GeoLocation-Package - This package helps you to know the current language of the user, the country from which he is browsing, the currency of his country, and also whether he is using it vpn

GeoLocation in PHP (API) 😍 😍 😍 This package helps you to know a lot of information about the current user by his ip address 😍 😍 😍 This package h

Comments
  • Log authentication info as a service

    Log authentication info as a service

    in LaravelScenarioLoggerMiddleware we have a method so all process will handles here

    public function handle($request, Closure $next)
        {
            if (lsl_is_active()) {
                ScenarioLogger::start();
                lsl_service_is_active('log-request') ? ScenarioLogger::logForService('log-request', $request) : null;
                Auth::check() ? ScenarioLogger::setUser(Auth::user()) : null;
                $response = $next($request);
                lsl_service_is_active('log-response') ? ScenarioLogger::logForService('log-response', $response) : null;
                ScenarioLogger::finish();
    
                return $response;
            } else {
                return $next($request);
            }
        }
    
    

    It would be more nice if middleware didn't have to be worry about user authentication

    'active-services' => [
            'log-model-changes',
            'log-request',
            'log-response',
            'log-exception',
            'log-manual-trace',
           // new feature requested 
            'log-user-authentication',
        ],
    

    and 'log-user-authentication' service will store user authentication logs

    enhancement 
    opened by debuqer 2
  • Ability to use another database config as default config

    Ability to use another database config as default config

    Some of developers are tend to isolate logs database rather than application database. it might be a good practice to set our database config name in config/laravel-scenario-logger.php

    'drivers' => [
            'database' => [
                'default-database-connection' => 'my_logs_storage_config',
            ]
        ],
    
    

    and in config/database.php we will have a connection named 'my_logs_storage_config'.

    Thank in advance

    opened by debuqer 1
Releases(v1.1.0)
Owner
Mehrdad Mahdian
Laravel Developer
Mehrdad Mahdian
PHP Simple Response, XML, JSON,... auto response with accept in request's header

simple-response Simple package to handle response properly in your API. This package does not include any dependency. Install Via Composer $ composer

Phuong Danh 3 Dec 8, 2021
Log activity inside your Laravel app

Log activity inside your Laravel app The spatie/laravel-activitylog package provides easy to use functions to log the activities of the users of your

Spatie 4.6k Jan 7, 2023
Update multiple Laravel Model records, each with it's own set of values, sending a single query to your database!

Laravel Mass Update Update multiple Laravel Model records, each with its own set of values, sending a single query to your database! Installation You

Jorge GonzΓ‘lez 88 Dec 31, 2022
Foreman is a Laravel scaffolding application that automates common tasks you typically perform with each new Laravel app you create

Foreman is a Laravel scaffolding application that automates common tasks you typically perform with each new Laravel app you create. The directives you want Forman to perform are outlined in a JSON based template file.

Indatus 145 Apr 13, 2022
Laravel Authentication Log is a package Log user authentication details and send new device notifications.

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

Anthony Rappa 540 Jan 5, 2023
Laravel Logable is a simple way to log http request in your Laravel application.

Laravel Logable is a simple way to log http request in your Laravel application. Requirements php >= 7.4 Laravel version >= 6.0 Installation composer

Sagar 6 Aug 25, 2022
Easily capture every incoming request and the corresponding outgoing response in your Laravel app.

Easily capture every incoming request and the corresponding outgoing response in your Laravel app. This package is designed to work only with the Lara

Mark Townsend 22 Nov 15, 2022
Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Indatus 197 Dec 30, 2022
A university system that creates a timetable programm for subjects,classes and teachers which is used to create a programm for each semester. All this served as a website.

Timetable-System-Generator A university system that creates a timetable programm for subjects,classes and teachers which is used to create a programm

null 3 Nov 19, 2022
Laravel telegram log is a package that can catch your logs all quite simply

Laravel Telegram log Laravel telegram log is a package that can catch your logs all quite simply. Requirments This package is tested with Laravel v8 i

Muath Alsowadi 4 Aug 3, 2022