jeremykenedy / laravel-logger

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+
MIT License
579 stars 120 forks source link

Calling static trait methods is deprecated #134

Closed filipz-proglove closed 9 months ago

filipz-proglove commented 2 years ago

Hello there. I am facing some warnings with this package, that I wanted to bring to attention. This wasn't the case until I updated PHP. It seems that calling some static trait methods is deprecated. As can be seen below :

[00:48:07] LOG.warning: Calling static trait method jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger::activity is deprecated, it should only be called on a class using the trait in vendor/jeremykenedy/laravel-logger/src/App/Http/Middleware/LogActivity.php on line 24
WARNINGLOG
[00:48:07] LOG.warning: Calling static trait method jeremykenedy\LaravelLogger\App\Http\Traits\ActivityLogger::storeActivity is deprecated, it should only be called on a class using the trait in /vendor/jeremykenedy/laravel-logger/src/App/Http/Traits/ActivityLogger.php on line 83

PHP version :

PHP 8.1.0 (cli) (built: Nov 23 2021 18:56:11) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies

OS :

Distributor ID: Ubuntu
Description:    Ubuntu 21.10
Release:    21.10
Codename:   impish

Also affects other package by the same author - LaravelBlocker

jeremykenedy\LaravelBlocker\App\Traits\IpAddressDetails::checkIP is deprecated, it should only be called on a class using the trait in /vendor/jeremykenedy/laravel-blocker/src/App/Traits/LaravelCheckBlockedTrait.php on line 22

filipz-proglove commented 2 years ago

In fact when combined with this issue :

https://github.com/barryvdh/laravel-debugbar/issues/1261

The debug bar becomes quite populated with useless warnings.

arborrow commented 1 year ago

I looked at a patch for a similar Drupal-related issue and suspect that it may be simply a matter or replacing the trait name with static. I will let @jeremykenedy look at that and test the functionality.

ajitdas123 commented 11 months ago

Hi @jeremykenedy , Can we update this? I checked changing public static function activity($description = null, $details = null) to public function activity($description = null, $details = null) inside ActivityLogger And using it like this

           //ActivityLogger::activity($description);
            $this->activity($description);

Does remove the warning logs. But don't know the drawback of making this function non-static. This would be nice if we could get rid of these warnings,

jeremykenedy commented 11 months ago

Solved with https://github.com/jeremykenedy/laravel-logger/pull/166

jeremykenedy commented 9 months ago

Rolling into issue #166