Giter Site home page Giter Site logo

jeremykenedy / laravel-logger Goto Github PK

View Code? Open in Web Editor NEW
563.0 34.0 121.0 304 KB

An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel 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. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+

License: MIT License

PHP 57.79% Blade 41.38% Hack 0.83%
laravel-logger laravel-logging activity activity-logger activity-logging request-logger request-logging logging logger activity-drilldown

laravel-logger's Introduction

Laravel Logger

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+

Latest Stable Version Total Downloads StyleCI Scrutinizer Code Quality License: MIT

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 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

🎞️ Video Tour

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

Integrations

Laravel logger can work out the box with or without the following roles packages:

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.

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

    '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)

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

    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:

    $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.

Environment File

Here are the .env file variables available:

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_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:

activity

Example to start recording page views using middlware in web.php:

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

This middlware can be enabled/disabled in the configuration settings.

Trait Usage

Events can be recorded directly by using the trait. When using the trait you can customize the event description.

To use the trait:

  1. Include the call in the head of your class file:

        use jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger;
  2. Include the trait call in the opening of your class:

        use ActivityLogger;
  3. You can record the activity my calling the traits method:

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

    Or as bellow to include extended activity details:

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

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

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:

'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.

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');
});

Search

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

.env file

add these configurations to your .env file to control the logging search

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

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

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 [email protected]
  • 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.

License

Laravel-logger is licensed under the MIT license. Enjoy!

laravel-logger's People

Contributors

alexandre433 avatar arborrow avatar atymic avatar azorpax avatar canerksk avatar dbotman avatar denydias avatar diatama avatar effeks avatar enkia avatar hittesh-ahuja-wdt avatar ibrahimmahfuz avatar jeremykenedy avatar kentdahl avatar kingcomp avatar kykaalvi avatar longelas avatar maxdestors avatar mohamedabouda avatar peyobr avatar rodrigoos098 avatar shailesh-ladumor avatar stylecibot avatar sudwebdesign avatar thenewsound avatar ulcuber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-logger's Issues

LARAVEL_LOGGER_USER_ID_FIELD

Your views does not fit your functional.

laravel-search.blade.php

	<select class="form-control" name="user">
		<option value="" selected>All</option>
			@foreach($users as $user)
			<option value="**{{$user->id}}**" {{request()->get('user') && request()->get('user') == $user->id ? 'selected':''}}>{{$user->name}}</option>
					@endforeach
		</select>

activity-log-item.blade.php


       @if($userDetails)

            <dt>{!! trans('LaravelLogger::laravel-logger.drilldown.list-group.labels.userId') !!}</dt>
                  <dd>{{**$userDetails->id}**}</dd>

         @if(config('LaravelLogger.rolesEnabled'))

Also, your pagination do not append query string to page lings

Laravel 7

Hi, do you plan to update larave-logger for Laravel 7 ? Now we have notices from composer

Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Controllers\LaravelLoggerController located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Controllers/LaravelLoggerController.php does not co
mply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Middleware\LogActivity located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Middleware/LogActivity.php does not comply with psr-4 autoloadin
g standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Traits/ActivityLogger.php does not comply with psr-4 autoloading
standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Traits\IpAddressDetails located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Traits/IpAddressDetails.php does not comply with psr-4 autoload
ing standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Traits\UserAgentDetails located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Traits/UserAgentDetails.php does not comply with psr-4 autoload
ing standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogAuthenticated located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogAuthenticated.php does not comply with psr-4 autoloading
standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogAuthenticationAttempt located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogAuthenticationAttempt.php does not comply with ps
r-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogFailedLogin located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogFailedLogin.php does not comply with psr-4 autoloading stan
dard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogLockout located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogLockout.php does not comply with psr-4 autoloading standard. It
 will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogPasswordReset located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogPasswordReset.php does not comply with psr-4 autoloading
standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogSuccessfulLogin located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogSuccessfulLogin.php does not comply with psr-4 autoload
ing standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Listeners\LogSuccessfulLogout located in ./vendor/jeremykenedy/laravel-logger/src/app/Listeners/LogSuccessfulLogout.php does not comply with psr-4 autolo
ading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Models\Activity located in ./vendor/jeremykenedy/laravel-logger/src/app/Models/Activity.php does not comply with psr-4 autoloading standard. It will not
autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

Activity Lot Item Blade Incorrect Variable Name

In line 383 of activity-log-item.blade.php it references an $activities variable. I think this should be $activity.

@if(config('LaravelLogger.loggerDatatables'))
        @if (count($activity) > 10)
            @include('LaravelLogger::scripts.datatables')
        @endif
@endif

tooltip fails requiring Popper.js

I get this error :
jquery-3.2.1.slim.min.js:2 Uncaught TypeError: Bootstrap tooltips require Popper.js

and the dropdown menu can't show up.

this is the layout I'm using :

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    @yield('template_linked_css')
  </head>
  <body>
    @yield('content')
    @yield('footer_scripts')
  </body>
</html>

pretty basic,

see screenshots of the errors :
Screenshot -  2019-06-20 à 11 47 47
Screenshot -  2019-06-20 à 11 48 04

any though ?

thanks, love

add model changes listener

Hello,
Can we add model changes listener instead of uses request method to figure out what is happened, and in some case send post request does not mean I created a new record.

I want to hear from you guys.

Tanks in advance

Logger doesn't work on Laravel 5.6

I've tried installing it by composer require jeremykenedy/laravel-logger but the files in src folder did not install in my app and it was on a fresh Laravel 5.6 app.

/src/app/Http/Middleware/LogActivity.php - Line No. 39 not updating while composer update

Dear Friend,
I installed version 1.1.0 with the composer.json entry "jeremykenedy/laravel-logger": "^1.0" but the update you mentioned in commits are not getting, still i am getting the file with out '[ ]' in shouldLog function.

protected function shouldLog($request)
    {
        foreach (config('LaravelLogger.loggerMiddlewareExcept') as $except) {
            if ($except !== '/') {
                $except = trim($except, '/');
            }

            if ($request->is($except)) {
                return false;
            }
        }

        return true;
    }

and this is throwing error, what procedure I need to follow to get the updated line number 39

thanks,
Anish

Logged IP is wrong if behind a proxy

I think the line
'ipAddress' => Request::ip(),
should be changed to something like
'ipAddress' => request()->server('HTTP_X_FORWARDED_FOR') ? request()->server('HTTP_X_FORWARDED_FOR') : Request::ip(),
if we want to log the real IP of the client (website behind Cloudflare, etc.)

Also, not sure of the utility of these lines in the IpAddressDetails Trait :

            if ($deep_detect) {
                if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) {
                    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
                }
                if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) {
                    $ip = $_SERVER['HTTP_CLIENT_IP'];
                }
            }

I think that should be done before the logging is persisted to database, otherwise the $_SERVER variables are out of context of the actual page visit.

Nova Panel

Do you planning to make a nova package for admin panel?

View [layouts.app] not found.

View [layouts.app] not found. (View: D:\Xampp\htdocs\laravel\vendor\jeremykenedy\laravel-logger\src\resources\views\logger\activity-log.blade.php)

User primary key

My user model has a custom primary key (integer, yes), and logger fetching only 'id' row. How to change it?

Thanks.

loadMigrationsFrom call causes mysql to be used even if pgsql is specified everywhere.

First off, love it... Great work. You have saved countless millions of developer hours because of the work you've done. Keep up the great work.

Buuuuuut... (sorry)...

Due to the call to loadMigrationsFrom in the service providers of this and other dependencies of laravel-auth, in conjunction with the vendor code being unaware of the configs above it in app/config, the vendor code always tries to use MySql, even if everything in the env and app/config says to use pgsql.

Please, please, puhleeze, make loadMigrationsFrom (and other vendor/location forcing) calls optional via top-level config. Publishing to app/database/migrations does not stop vendor code from running in loadMigrationsFrom is called in your providers register/boot functions.

Despite the appearance below, all my other tables are created in the Pgsql database, but processing stops when it hits laravel-logger (and other laravel-auth deps)...

1   PDOException::("PDO::__construct(): MySQL server has gone away")
    /Users/devdude/Projects/mydb.dev/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27

2   PDO::__construct("mysql:host=127.0.0.1;port=5432;dbname=mydb", "mydb", "mydb", [])
    /Users/devdude/Projects/mydb.dev/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27

3   Doctrine\DBAL\Driver\PDOConnection::__construct("mysql:host=127.0.0.1;port=5432;dbname=mydb", "mydb", "mydb", [])
    /Users/devdude/Projects/mydb.dev/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67

4   Illuminate\Database\Connectors\Connector::createPdoConnection("mysql:host=127.0.0.1;port=5432;dbname=mydb", "mydb", "mydb", [])
    /Users/devdude/Projects/mydb.dev/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:100

5   Illuminate\Database\Connectors\Connector::tryAgainIfCausedByLostConnection(Object(Doctrine\DBAL\Driver\PDOException), "mysql:host=127.0.0.1;port=5432;dbname=mydb", "mydb", "mydb", [])


Conclusion: remove laravel/framework v5.1.46

I'm running Laravel 5.1 and I keep getting this error when I try to install this plugin:

Problem 1
- The requested package laravelcollective/html (locked at v5.1.11, required as ^5.8.0) is satisfiable by laravelcollective/html[v5.1.11] but these conflict with your requirements or minimum-stability.

I think I'm locked to the laravelcollective/html[v5.1.11] because I'm on Laravel 5.1.46. I'm following the guide by using "composer require jeremykenedy/laravel-logger" but it fails. I was able to install an older version successfully by running "composer require jeremykenedy/laravel-logger:dev-bootstrap3"

Class 'Crawler' not found

After Install jeremykenedy/laravel-logger i got FatalThrowableError Class 'Crawler' not found in ActivityLogger.php line 29

Add German Languagefile (de)

Thank you verymuch for this project. I am using this according to Laravel-Auth, and I am missing the German-Language-File.

I have overwritten the Language-Files at the moment, because it is showing wrong titles.
To be more attractive for German Users I've added my Language-Proposal for German above:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Language Lines - Global
    |--------------------------------------------------------------------------
    */
    'userTypes' => [
        'guest'      => 'Gast',
        'registered' => 'Registriert',
        'crawler'    => 'Suchmaschine',
    ],

    'verbTypes' => [
        'created'    => 'Erstellt',
        'edited'     => 'Bearbeitet',
        'deleted'    => 'Gelöscht',
        'viewed'     => 'Angesehen',
        'crawled'    => 'Gesucht (Crwaler)',
    ],

    'tooltips' => [
        'viewRecord' => 'Details anzeigen',
    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Admin Dashboard Language Lines
    |--------------------------------------------------------------------------
    */
    'dashboard' => [
        'title'     => 'Aktivitätslog',
        'subtitle'  => 'Ereignisse',

        'labels'    => [
            'id'            => 'ID',
            'time'          => 'Zeit',
            'description'   => 'Beschreibung',
            'user'          => 'Nutzer',
            'method'        => 'Methode',
            'route'         => 'Route',
            'ipAddress'     => 'IP <span class="hidden-sm hidden-xs">Adresse</span>',
            'agent'         => '<span class="hidden-sm hidden-xs">User </span>Agent',
            'deleteDate'    => 'Deleted <span class="hidden-sm hidden-xs">am</span>',
        ],

        'menu'      => [
            'alt'           => 'Aktivitätslog Menü',
            'clear'         => 'Lösche Aktivitätslog',
            'show'          => 'Zeige gelöschte Logs',
            'back'          => 'Zurück zum Log',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Admin Drilldown Language Lines
    |--------------------------------------------------------------------------
    */

    'drilldown' => [
        'title'                 => 'Aktivitätslog :id',
        'title-details'         => 'Aktivitätsdetails',
        'title-ip-details'      => 'IP Informationen',
        'title-user-details'    => 'Nutzer Informationen',
        'title-user-activity'   => 'Nutzer Aktivität',

        'buttons'   => [
            'back'      => '<span class="hidden-xs hidden-sm">Zurück zum </span><span class="hidden-xs">Aktivitätslog</span>',
        ],

        'labels' => [
            'userRoles'     => 'Nutzerrolle',
            'userLevel'     => 'Level',
        ],

        'list-group' => [
            'labels'    => [
                'id'            => 'Aktivitätslog ID:',
                'ip'            => 'IP Adresse',
                'description'   => 'Beschreibung',
                'userType'      => 'Nutzertyp',
                'userId'        => 'Nutzer ID',
                'route'         => 'Route',
                'agent'         => 'User Agent',
                'locale'        => 'Sprache',
                'referer'       => 'Referer (Ursprung)',

                'methodType'    => 'Methoden Typus',
                'createdAt'     => 'Ereignisausführung',
                'updatedAt'     => 'Bearbeitet am',
                'deletedAt'     => 'Gelöscht am',
                'timePassed'    => 'Letzte Aktivität',
                'userName'      => 'Nutzer',
                'userFirstName' => 'Vorname',
                'userLastName'  => 'Nachname',
                'userFulltName' => 'Name',
                'userEmail'     => 'Email',
                'userSignupIp'  => 'Anmelde Ip',
                'userCreatedAt' => 'Erstellt',
                'userUpdatedAt' => 'Bearbeitet',
            ],
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Modals
    |--------------------------------------------------------------------------
    */

    'modals' => [
        'shared' => [
            'btnCancel'     => 'Abbrechen',
            'btnConfirm'    => 'Bestätigen',
        ],
        'clearLog' => [
            'title'     => 'Lösche Aktivitätslog',
            'message'   => 'Sind Sie sicher, dass Sie das Aktivitätslog löschen möchten?',
        ],
        'deleteLog' => [
            'title'     => 'Unwiederbringliches Löschen des Aktivitätslogs',
            'message'   => 'Sind Sie sicher, dass Sie das Aktivitätslog löschen möchten?',
        ],
        'restoreLog' => [
            'title'     => 'Wiederherstellen des Aktivitätslogs',
            'message'   => 'Sind Sie sicher, dass Sie das Aktivitätslog wiederherstellen möchten?',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Flash Messages
    |--------------------------------------------------------------------------
    */

   'messages' => [
        'logClearedSuccessfuly' => 'Aktivitätslog erfolgreich geleert',
        'logDestroyedSuccessfuly' => 'Aktivitätslog erfolgreich gelöscht',
        'logRestoredSuccessfuly' => 'Aktivitätslog erfolgreich wiederhergestellt',
   ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Cleared Dashboard Language Lines
    |--------------------------------------------------------------------------
    */

    'dashboardCleared' => [
        'title'     => 'Gelöschte Aktivitäten',
        'subtitle'  => 'Gelöschte Ereignisse',

        'menu'      => [
            'deleteAll'  => 'Lösche alle Aktivitäten',
            'restoreAll' => 'Aktivitäten wiederherstellen',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Laravel Logger Pagination Language Lines
    |--------------------------------------------------------------------------
    */
    'pagination' => [
        'countText' => 'Zeige :firstItem - :lastItem von :total Einträgen <small>(:perPage je Seite)</small>',
    ],

];

Feature: Allow customisation of routes

I think this would be a good feature to add.

I think the best way to do this would be similar to how the base laravel auth routes are registered.

You would add LaravelLogger::routes() to your routes file for your app, and this would take an array of config options, such as:

  • route prefix
  • route name prefix
  • middleware
  • routes to disable
    etc

This would be applied to the routes, which would then be added to the app's router routes.
Obviously would have to make it backwards compatible.

The other way would be to allow you to disable the routes with a config option, and then you could add them yourself to your routes file (using the full controller namespace + name)

I'll try and get a PR up when I have a chance :)

This is related to #17

Object not found! when opening log details

First of all, great package.

However I am facing this problem when I try to drill down on an activity, to get all the details.

When I was developing using pa serve, I had no challenges regarding to this, I could view all the details of an activity. But Im now running my project without pa serve, directly in the WebBrowser I type: localhost/myproject to access my project.

however when I try to drill down on an activity its redirecting to: http://localhost/activity/log/1087 and if I manually include myproject .i.e. http://localhost/myproject/activity/log/1087 its opening just fine.

I tried changing the URL in \vendor\jeremykenedy\laravel-logger\src\resources\views\logger\partials\activity-table.blade.php from $prependUrl = '/activity/log/'; to $prependUrl = '/myproject/activity/log/'; then ran php config:cache, route:cache,view:cache. It did not change anything.

I also tried changing the URL format to {{url('/myproject/activity/log/')}} but that did not change anything as well.

Composer update LaravelLoggerServiceProvider error

Hey there! I ran composer update this morning on a project of mine, and I got this strange message:

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In LaravelLoggerServiceProvider.php line 105:

  Call to undefined method Event::listen()


Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I can't seem to debug the issue but if I run the following the error goes away:

composer remove jeremykenedy/laravel-logger

Dependency "jaybizzle/laravel-crawler-detect" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Removing jeremykenedy/laravel-logger (v2.4.2)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: barryvdh/laravel-debugbar
Discovered... (truncated for brevity, 30 more lines of successful discovered packages)
Package manifest generated successfully.

However if I require it again, the error comes back:

composer require jeremykenedy/laravel-logger

Using version ^2.4 for jeremykenedy/laravel-logger
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing jeremykenedy/laravel-logger (v2.4.2): Loading from cache
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In LaravelLoggerServiceProvider.php line 105:

  Call to undefined method Event::listen()


Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I'm just not sure why this is happening, nor how to get around it. Curious if anyone else is experiencing this issue, or if it might be unique to my project. Thanks!

sudo chmod -R 755 ../laravel-auth

Sincerely I read the instruction before making an issue but I do not know what step to take about this as i get 'sudo' not a recognised command when i run this 'sudo chmod -R 755 ../laravel-auth' please what do i do am stucked.

User field gets empty value in some cases.

I don't know what is your criteria for checking the user name. But most of my entires have the user coming as nothing. its empty.
userid column is getting filled as null in most of the cases.

Feature: Add a different user when logging an activity.

Hi,

I have just come across an issue when using the logger to log what happens inside a JOB. The activity is recorded as 'guest'

Being able to do something like the following would be helpful in this instance :
ActivityLogger::activity("I have logged something.", $activeUser);

Regards

Deprecation Notice

Deprecation Notice: Class jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger located in ./vendor/jeremykenedy/laravel-logger/src/app/Http/Traits/ActivityLogger.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

The above error is shown whenever you run composer dumpautoload

User Agent is not correctly parsed

Hello Jeremy,

first of all, nice project. Well done.

I noticed, that the User Agent in the List of Activites of Laravel-Auth Project is not properly displayed.
To do so I overrided the View. But instead it would be better to override the model. (That shouldnt be done by me - due to updates or so)

My fix is:
Added before Line 153 of File resources/views/logger/partials/activity-table.blade.php

that:

$userAgentDetails = \jeremykenedy\LaravelLogger\App\Http\Traits\UserAgentDetails::details($activity->userAgent);

and changed following 3 Lines.

Your Fix I would recommend would be adding to the Model of Activity this Function:

public function getUserAgentDetailsAttribute() {
  return \jeremykenedy\LaravelLogger\App\Http\Traits\UserAgentDetails::details($this->userAgent);
}

I hope I could help you with that.

PrimeGhost

Unable to load log file.

When i was trying to go to /logs , it able to display the log . But when i was trying to select the log file based on date, it shows
Illuminate \ Contracts \ Encryption \ DecryptException
The payload is invalid.

i can only fix this problem by command out the line 46 and 50 in logviewercontroller.

Is there any other way i can fix this error?

image

mongoDB

not working with mongodb , any chance u can update it to do so ?

laravelcollective/html missing in dependencies

note : I did read the instructions for opening an issue.

On a fresh install, here is the history :

composer global require laravel/installer\n
laravel new logger-error
cd logger-error
php artisan make:auth
php artisan migrate
composer require jeremykenedy/laravel-logger
php artisan migrate
php artisan vendor:publish --tag=LaravelLogger

when fetching this url : http://logger-error.test/activity
I get :

Class 'Form' not found (View: /Users/vwasteels/code/logger-error/resources/views/vendor/LaravelLogger/forms/clear-activity-log.blade.php) (View: /Users/vwasteels/code/logger-error/resources/views/vendor/LaravelLogger/forms/clear-activity-log.blade.php)

Solved with :
composer require "laravelcollective/html":"^5.8.0"

Class 'Locale' not found

Hi Jeremy,
I faced with an error when I use it for the first time! it throws (Class 'Locale' not found) in /activity route.
Please share a trick to fix that. thanks.

Lumen support

Your package supports Lumen with a few small tweaks (modify routing/no 'views' possible) I guess.
It may be nice to look into this? Won't take long I guess.

Love the package.

App/config is not over writing vendor/config

I was having trouble installing this package until I realized that the app/config file was not taking precedence over the package config file.

I haven't had a chance to do a deeper discovery yet. I will report back if I find a solution.

Activities

in
Vendor/jeremyKenedy/Laravel-logger/src/app/Http/Controllers/LaravelLoggerController.php

in the function ShowAccessLog, the view for this is trying to find "$activities" which doesnt exist in the function,

work around is just to copy from the function above the activities declaration and put it in but I am not sure what was intended here so didnt want to assume a correct fix

kind regards
Robert

multiple custom defaultUserIDField and defaultUserModel

Hello ,
I user laravel 5.8 and i have two table fos two differents ayhtenticate milddleware.
Tablem User_client ( with defaultUserIDField 'id') and table Administrators ( with defaultUserIDField 'idadmin')
My question is how to implements those mutilple custom Id and mutilple custom Models in laravel-logger.php file or .env?
thank

The referer format is invalid

[2018-10-01 17:46:26] production.ERROR: Failed to record activity event. Failed Validation: {"referer":["The referer format is invalid."]}
[2018-10-02 22:00:08] production.ERROR: Failed to record activity event. Failed Validation: {"referer":["The referer format is invalid."]}
[2018-10-02 22:00:27] production.ERROR: Failed to record activity event. Failed Validation: {"referer":["The referer format is invalid."]}
[2018-10-02 23:07:16] production.ERROR: Failed to record activity event. Failed Validation: {"referer":["The referer format is invalid."]}
[2018-10-02 23:10:11] production.ERROR: Failed to record activity event. Failed Validation: {"referer":["The referer format is invalid."]}

any idea what causes this?

Clear activity doesn't work

First of all, AMAZING JOB!!!

The issue:

When clicking on Clear Activity Log, and then click on Confirm in the confirmation modal, it does nothing, no closing the modal, no sending the request, no js error.

Also, I set to false the use of all the js/css files: jquery, bootstrap, etc
I am using instead:

  • jquery 3.3.1
  • propper 1.14.7
  • bootstrap 4.3.1

I can also confirm that none of the confirms modals are working for me. I assume it could be js related since I changed the button type to submit on all of them and the forms are submitted (clear logs, restore logs, delete logs).

I hope this info helps.

Cheers,
Sam

Middleware: exclusion by route/url pattern

Is it possible to add this feature to exclude some URL pattern?
e.g.
mywebsite.com/refresh/user/status
mywebsite.com/refresh/user/notification
mywebsite.com/refresh/user/message

all with refresh/user/* URL pattern will not log

config file not loading in project config folder

Hello,

Firstly thanks for this plugin. But, I have an issue. When I change "loggerBladeExtended" in config file, nothing change. But, if i change in vendor config file then it's changing. I don't want to any change in vendor files.

Can you help me for this issue?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.