Update path of log files
This commit is contained in:
parent
b047ee8fda
commit
bf9342847f
47
app/Providers/LogServiceProvider.php
Normal file
47
app/Providers/LogServiceProvider.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Log;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class LogServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Log::getMonolog()->popHandler();
|
||||
Log::useFiles($this->getLogPath());
|
||||
|
||||
if (! config('app.debug')) {
|
||||
$this->deleteLogs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
protected static function getLogPath()
|
||||
{
|
||||
$mask = substr(md5(implode(',', array_values(get_db_config()))), 0, 16);
|
||||
|
||||
return storage_path("logs/bs-$mask.log");
|
||||
}
|
||||
|
||||
protected function deleteLogs()
|
||||
{
|
||||
@unlink($this->getLogPath());
|
||||
@unlink(storage_path('logs/laravel.log'));
|
||||
}
|
||||
}
|
||||
|
|
@ -168,6 +168,7 @@ return [
|
|||
*/
|
||||
App\Providers\BootServiceProvider::class,
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\LogServiceProvider::class,
|
||||
App\Providers\PluginServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\MemoryServiceProvider::class,
|
||||
|
|
|
|||
1
storage/logs/.gitignore
vendored
1
storage/logs/.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
*
|
||||
!.gitignore
|
||||
!index.html
|
||||
|
|
|
|||
0
storage/logs/index.html
Normal file
0
storage/logs/index.html
Normal file
Loading…
Reference in New Issue
Block a user