2017 © Pedro Pelรกez
 

package laravel-logger

Laravel Logger Package

image

jeremykenedy/laravel-logger

Laravel Logger Package

  • Saturday, June 23, 2018
  • by jeremykenedy
  • Repository
  • 7 Watchers
  • 76 Stars
  • 9,743 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 1 Open issues
  • 13 Versions
  • 34 % Grown

The README.md

Laravel Logger, (*1)

Laravel Activity Logger

Laravel logger is an activity event logger for your Laravel or Lumen application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. Easily have an Activity Log. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, 7, 8 and 9+, (*2)

Latest Stable Version Total Downloads StyleCI Scrutinizer Code Quality License: MIT, (*3)

Table of contents

Features

Laravel Activity Logger Features
Logs login page visits
Logs user logins
Logs user logouts
Routing Events can recording using middleware
Records activity timestamps
Records activity description
Records activity details (optional)
Records model related to the activity (optional)
Records activity user type with crawler detection
Records activity Method
Records activity Route
Records activity Ip Address
Records activity User Agent
Records activity Browser Language
Records activity referrer
Customizable activity model
Activity panel dashboard
Individual activity drilldown report dashboard
Activity Drilldown looks up Id Address meta information
Activity Drilldown shows user roles if enabled
Activity Drilldown shows associated user events
Activity log can be cleared, restored, and destroyed using eloquent softdeletes
Cleared activity logs can be viewed and have drilldown ability
Uses font awesome, cdn assets can be optionally called in configuration
Uses Geoplugin API for drilldown IP meta information
Uses Language localization files
Lots of configuration options

Requirements

:film_strip: Video Tour

If you'd prefer a more visual review of this package, please watch this video on Laravel Package Tutorial., (*4)

, (*5)

Integrations

Laravel logger can work out the box with or without the following roles packages: * jeremykenedy/laravel-roles * spatie/laravel-permission * Zizaco/entrust * romanbican/roles * ultraware/roles, (*6)

Laravel Installation Instructions

  1. From your projects root folder in terminal run:
    composer require jeremykenedy/laravel-logger
  1. Register the package
  • Laravel 5.5 and up Uses package auto discovery feature, no need to edit the config/app.php file., (*7)

  • Laravel 5.4 and below Register the package with laravel in config/app.php under providers with the following:, (*8)

    'providers' => [
        jeremykenedy\LaravelLogger\LaravelLoggerServiceProvider::class,
    ];
  1. Run the migration to add the table to record the activities to:
    php artisan migrate
  • Note: If you want to specify a different table or connection make sure you update your .env file with the needed configuration variables.
  1. Optionally Update your .env file and associated settings (see Environment File section), (*9)

  2. Optionally publish the packages views, config file, assets, and language files by running the following from your projects root folder:, (*10)

    php artisan vendor:publish --tag=LaravelLogger

Lumen Installation Instructions

This installs laravel-logger without the GUI
  1. From your projects root folder in terminal run:
    composer require jeremykenedy/laravel-logger
  1. Register the package

Register the package with laravel in bootstrap/app.php with the following:, (*11)

    $app->register(\Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider::class);
    $app->configure('laravel-logger');
    $app->register(\jeremykenedy\LaravelLogger\LaravelLoggerServiceProvider::class);
    $app->routeMiddleware(['activity' => \jeremykenedy\LaravelLogger\App\Http\Middleware\LogActivity::class, ]);
  1. Copy the configuration file laravel-logger.php to your config/ directory
Set LARAVEL_LOGGER_DISABLE_ROUTES=true in your .env file!
  1. Run the migration to add the table to record the activities to:
    php artisan migrate
  • Note: If you want to specify a different table or connection make sure you update your .env file with the needed configuration variables.
  1. Optionally Update your .env file and associated settings (see Environment File section)

Configuration

Laravel Activity Logger can be configured in directly in /config/laravel-logger.php if you published the assets. Or you can variables to your .env file., (*12)

Environment File

Here are the .env file variables available:, (*13)

LARAVEL_LOGGER_DATABASE_CONNECTION=mysql
LARAVEL_LOGGER_DATABASE_TABLE=laravel_logger_activity
LARAVEL_LOGGER_ROLES_ENABLED=true
LARAVEL_LOGGER_ROLES_MIDDLWARE=role:admin
LARAVEL_LOGGER_MIDDLEWARE_ENABLED=true
LARAVEL_LOGGER_MIDDLEWARE_EXCEPT=
LARAVEL_LOGGER_ACTIVITY_MODEL=jeremykenedy\LaravelLogger\App\Models\Activity
LARAVEL_LOGGER_USER_MODEL=App\User
LARAVEL_LOGGER_USER_ID_FIELD=id
LARAVEL_LOGGER_DISABLE_ROUTES=false
LARAVEL_LOGGER_PAGINATION_ENABLED=true
LARAVEL_LOGGER_CURSOR_PAGINATION_ENABLED=false
LARAVEL_LOGGER_PAGINATION_PER_PAGE=25
LARAVEL_LOGGER_DATATABLES_ENABLED=true
LARAVEL_LOGGER_ENABLE_SEARCH=true
LARAVEL_LOGGER_SEARCH_FIELDS=description,user,method,route,ip
LARAVEL_LOGGER_DASHBOARD_MENU_ENABLED=true
LARAVEL_LOGGER_DASHBOARD_DRILLABLE=true
LARAVEL_LOGGER_LOG_RECORD_FAILURES_TO_FILE=true
LARAVEL_LOGGER_FLASH_MESSAGE_BLADE_ENABLED=true
LARAVEL_LOGGER_LAYOUT=layouts.app
LARAVEL_LOGGER_BOOTSTRAP_VERSION=4
LARAVEL_LOGGER_BLADE_PLACEMENT=stack                    #option: yield or stack
LARAVEL_LOGGER_BLADE_PLACEMENT_CSS=css-header           #placement name
LARAVEL_LOGGER_BLADE_PLACEMENT_JS=scripts-footer        #placement name
LARAVEL_LOGGER_JQUERY_CDN_ENABLED=true
LARAVEL_LOGGER_JQUERY_CDN_URL=https://code.jquery.com/jquery-2.2.4.min.js
LARAVEL_LOGGER_BOOTSTRAP_CSS_CDN_ENABLED=true
LARAVEL_LOGGER_BOOTSTRAP_CSS_CDN_URL=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css
LARAVEL_LOGGER_BOOTSTRAP_JS_CDN_ENABLED=true
LARAVEL_LOGGER_BOOTSTRAP_JS_CDN_URL=https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js
LARAVEL_LOGGER_POPPER_JS_CDN_ENABLED=true
LARAVEL_LOGGER_POPPER_JS_CDN_URL=https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js
LARAVEL_LOGGER_FONT_AWESOME_CDN_ENABLED=true
LARAVEL_LOGGER_FONT_AWESOME_CDN_URL=https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css

Usage

Middleware Usage

Events for laravel authentication scaffolding are listened for as providers and are enabled via middleware. You can add events to your routes and controllers via the middleware:, (*14)

activity

Example to start recording page views using middlware in web.php:, (*15)

Route::group(['middleware' => ['web', 'activity']], function () {
    Route::get('/', 'WelcomeController@welcome')->name('welcome');
});

This middlware can be enabled/disabled in the configuration settings., (*16)

Trait Usage

Events can be recorded directly by using the trait. When using the trait you can customize the event description., (*17)

To use the trait: 1. Include the call in the head of your class file:, (*18)

```php
    use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
```
  1. Include the trait call in the opening of your class:, (*19)

        use ActivityLogger;
    
  2. You can record the activity by calling the traits method:, (*20)

        ActivityLogger::activity("Logging this activity.");
    

    Or as bellow to include extended activity details:, (*21)

        ActivityLogger::activity("Logging this activity.", "Additional activity details.");
    

    Or even including the model related to the activity:, (*22)

        ActivityLogger::activity("Logging this activity.", "Additional activity details.", ["id" => 1, "model" => "App\Models\User"]);
    

Routes

Laravel Activity Dashbaord Routes
  • /activity
  • /activity/cleared
  • /activity/log/{id}
  • /activity/cleared/log/{id}

Custom package routes

If you wish to change the route paths, names or other options you can disable the default routes in your .env file by setting, (*23)

LARAVEL_LOGGER_DISABLE_ROUTES=true

If you are on an existing install, you will also need update your laravel-logger.php config file to add the config option:, (*24)

'disableRoutes' => env('LARAVEL_LOGGER_DISABLE_ROUTES', false),

You can then add the routes directly to your application's routes/web.php file, and customise as required., (*25)

Route::group(['prefix' => 'activity', 'namespace' => 'jeremykenedy\LaravelLogger\App\Http\Controllers', 'middleware' => ['web', 'auth', 'activity']], function () {

    // Dashboards
    Route::get('/', 'LaravelLoggerController@showAccessLog')->name('activity');
    Route::get('/cleared', ['uses' => 'LaravelLoggerController@showClearedActivityLog'])->name('cleared');

    // Drill Downs
    Route::get('/log/{id}', 'LaravelLoggerController@showAccessLogEntry');
    Route::get('/cleared/log/{id}', 'LaravelLoggerController@showClearedAccessLogEntry');

    // Forms
    Route::delete('/clear-activity', ['uses' => 'LaravelLoggerController@clearActivityLog'])->name('clear-activity');
    Route::delete('/destroy-activity', ['uses' => 'LaravelLoggerController@destroyActivityLog'])->name('destroy-activity');
    Route::post('/restore-log', ['uses' => 'LaravelLoggerController@restoreClearedActivityLog'])->name('restore-activity');
});

adding dynamic search fields (description , user, URL , method and ip address), (*26)

High Performance Paginator

When dealing with millions activity records, default behavior of not paginate records or Laravel's paginator (enabled LARAVEL_LOGGER_PAGINATION_ENABLED=true) may lead to huge performance penalties. For that use case you may set LARAVEL_LOGGER_CURSOR_PAGINATION_ENABLED=true to enable Laravel's Cursor Pagination feature. This will heavily improve Laravel Logger page loading time. If you choose to do so it's advisable to read Cursor vs. Offset Pagination section on Laravel's documentation to get acquainted with Cursor Pagination limitations., (*27)

.env file

add these configurations to your .env file to control the logging search, (*28)

LARAVEL_LOGGER_ENABLE_SEARCH=true
// you can customize your search using these options [description,user,method,route,ip]
LARAVEL_LOGGER_SEARCH_FIELDS=description,user,method,route,ip

by default all search fields are enabled when you enable the search with this one line configuration, (*29)

LARAVEL_LOGGER_SEARCH_ENABLE=true

Screenshots

dashboard drilldown confirm-clear log-cleared-msg cleared-log confirm-restore confirm-destroy success-destroy success-restored cleared-drilldown, (*30)

File Tree

โ”œโ”€โ”€ .env.travis
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ .travis.yml
โ”œโ”€โ”€ CODE_OF_CONDUCT.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ composer.json
โ””โ”€โ”€ src
    โ”œโ”€โ”€ .env.example
    โ”œโ”€โ”€ LaravelLoggerServiceProvider.php
    โ”œโ”€โ”€ app
    โ”‚ย ย  โ”œโ”€โ”€ Http
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Controllers
    โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ LaravelLoggerController.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Middleware
    โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ LogActivity.php
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Traits
    โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ ActivityLogger.php
    โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ IpAddressDetails.php
    โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ UserAgentDetails.php
    โ”‚ย ย  โ”œโ”€โ”€ Listeners
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogAuthenticated.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogAuthenticationAttempt.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogFailedLogin.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogLockout.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogPasswordReset.php
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LogSuccessfulLogin.php
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ LogSuccessfulLogout.php
    โ”‚ย ย  โ”œโ”€โ”€ Logic
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ helpers.php
    โ”‚ย ย  โ””โ”€โ”€ Models
    โ”‚ย ย      โ””โ”€โ”€ Activity.php
    โ”œโ”€โ”€ config
    โ”‚ย ย  โ””โ”€โ”€ laravel-logger.php
    โ”œโ”€โ”€ database
    โ”‚ย ย  โ””โ”€โ”€ migrations
    โ”‚ย ย      โ””โ”€โ”€ 2017_11_04_103444_create_laravel_logger_activity_table.php
    โ”œโ”€โ”€ resources
    โ”‚ย ย  โ”œโ”€โ”€ lang
    โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ de
    โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ laravel-logger.php
    โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ en
    โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ laravel-logger.php
    โ”‚ย ย  โ””โ”€โ”€ views
    โ”‚ย ย      โ”œโ”€โ”€ forms
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ clear-activity-log.blade.php
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ delete-activity-log.blade.php
    โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ restore-activity-log.blade.php
    โ”‚ย ย      โ”œโ”€โ”€ logger
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ activity-log-cleared.blade.php
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ activity-log-item.blade.php
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ activity-log.blade.php
    โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ partials
    โ”‚ย ย      โ”‚ย ย      โ””โ”€โ”€ activity-table.blade.php
    โ”‚ย ย      โ”œโ”€โ”€ modals
    โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ confirm-modal.blade.php
    โ”‚ย ย      โ”œโ”€โ”€ partials
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ form-search.blade.php
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ form-status.blade.php
    โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ scripts.blade.php
    โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ styles.blade.php
    โ”‚ย ย      โ””โ”€โ”€ scripts
    โ”‚ย ย          โ”œโ”€โ”€ add-title-attribute.blade.php
    โ”‚ย ย          โ”œโ”€โ”€ clickable-row.blade.php
    โ”‚ย ย          โ”œโ”€โ”€ confirm-modal.blade.php
    โ”‚ย ย          โ”œโ”€โ”€ datatables.blade.php
    โ”‚ย ย          โ””โ”€โ”€ tooltip.blade.php
    โ””โ”€โ”€ routes
        โ””โ”€โ”€ web.php
  • Tree command can be installed using brew: brew install tree
  • File tree generated using command tree -a -I '.git|node_modules|vendor|storage|tests'

Opening an Issue

Before opening an issue there are a couple of considerations: * You are all awesome! * Read the instructions and make sure all steps were followed correctly. * Check that the issue is not specific to your development environment setup. * Provide duplication steps. * Attempt to look into the issue, and if you have a solution, make a pull request. * Show that you have made an attempt to look into the issue. * Check to see if the issue you are reporting is a duplicate of a previous reported issue. * Following these instructions show me that you have tried. * If you have a questions send me an email to jeremykenedy@gmail.com * Need some help, I can do my best on Slack: https://opensourcehelpgroup.slack.com * Please be considerate that this is an open source project that I provide to the community for FREE when opening an issue., (*31)

License

Laravel-logger is licensed under the MIT license. Enjoy!, (*32)

The Versions

23/06 2018

dev-master

9999999-dev

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

04/05 2018

v2.2.0

2.2.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

13/04 2018

dev-analysis-qJ1x3Q

dev-analysis-qJ1x3Q

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

13/04 2018

v2.1.0

2.1.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

09/04 2018

5.6.x-dev

5.6.9999999.9999999-dev

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

09/04 2018

v2.0.0

2.0.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

laravel logger laravel activity laravel activity logger laravel activity log laravel log

26/03 2018

1.1.0

1.1.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

26/03 2018

dev-bootstrap3

dev-bootstrap3

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

22/01 2018

v1.0.1

1.0.1.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

10/11 2017

v1.0.0

1.0.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

08/11 2017

v0.5.0

0.5.0.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

08/11 2017

v0.0.2

0.0.2.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy

08/11 2017

v0.0.1

0.0.1.0

Laravel Logger Package

  Sources   Download

MIT

The Requires

 

by Avatar jeremykenedy