Update logging service
This commit is contained in:
parent
9f0e08b84f
commit
bfd71feac0
41
app/Providers/LogServiceProvider.php
Normal file
41
app/Providers/LogServiceProvider.php
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Log;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class LogServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Log::channel('single')->popHandler();
|
||||||
|
config(['logging.channels.single.path' => $this->getLogPath()]);
|
||||||
|
|
||||||
|
if (! config('app.debug')) {
|
||||||
|
@unlink(storage_path('logs/laravel.log'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -182,6 +182,7 @@ return [
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
App\Providers\PluginServiceProvider::class,
|
App\Providers\PluginServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
|
App\Providers\LogServiceProvider::class,
|
||||||
App\Providers\MemoryServiceProvider::class,
|
App\Providers\MemoryServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
App\Providers\ResponseMacroServiceProvider::class,
|
App\Providers\ResponseMacroServiceProvider::class,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ return [
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'default' => env('LOG_CHANNEL', 'stack'),
|
'default' => env('LOG_CHANNEL', 'single'),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user