From: Vincent Vanwaelscappel Date: Thu, 8 Jun 2023 13:41:06 +0000 (+0200) Subject: wip #6009 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3d639f028051aab31b8cea748543805d8975b78d;p=fluidbook-toolbox.git wip #6009 @0.5 --- diff --git a/.env.dev b/.env.dev index 088dccccb..10b54ac76 100644 --- a/.env.dev +++ b/.env.dev @@ -7,6 +7,7 @@ DEBUGBAR_ENABLED=true APP_URL=https://dev.toolbox.fluidbook.com HEADER_COLOR="#df4759" + LOG_CHANNEL=stack APP_LOG=daily diff --git a/app/Logging/SlackFormatter.php b/app/Logging/SlackFormatter.php new file mode 100644 index 000000000..e31958c1a --- /dev/null +++ b/app/Logging/SlackFormatter.php @@ -0,0 +1,51 @@ +request = $request; + } + + public function __invoke($logger) + { + foreach ($logger->getHandlers() as $handler) { + if ($handler instanceof SlackWebhookHandler) { + $handler->setFormatter(new LineFormatter( + '[%datetime%] %channel%.%level_name%: %message% %context% %extra%' + )); + + $handler->pushProcessor([$this, 'processLogRecord']); + } + } + } + + public function processLogRecord(LogRecord $record): LogRecord + { + + if ($this->request) { + $record->extra += [ + 'URL' => $this->request->url(), + ]; + } + /** @var User $user */ + $user = backpack_user(); + if ($user) { + $record->extra += [ + 'user' => $user->getNameAttribute() . ' (' . $user->id . ')', + ]; + } + + return $record; + } +} diff --git a/composer.json b/composer.json index 15454517f..9dc589110 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "php-ffmpeg/php-ffmpeg": "^v1.1.0", "rodneyrehm/plist": "^2.0", "rustici-software/scormcloud-api-v2-client-php": "^2.1.0", - "symfony/http-client": "^v6.3.0" + "symfony/http-client": "^v6.3.0", }, "require-dev": { "spatie/laravel-ignition": "^2.1.3", diff --git a/config/logging.php b/config/logging.php index a72b700b9..239989aed 100644 --- a/config/logging.php +++ b/config/logging.php @@ -56,6 +56,7 @@ return [ 'slack' => [ 'driver' => 'slack', + 'tap' => [\App\Logging\SlackFormatter::class], 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', diff --git a/resources/views/vendor/backpack/base/dashboard.blade.php b/resources/views/vendor/backpack/base/dashboard.blade.php index db8e3d162..29a1198f2 100644 --- a/resources/views/vendor/backpack/base/dashboard.blade.php +++ b/resources/views/vendor/backpack/base/dashboard.blade.php @@ -2,6 +2,7 @@ @extends(backpack_view('blank')) @php + \Illuminate\Support\Facades\Log::warning('test !!'); \App\Widgets::fluidbookQuoteWidgets(); \App\Widgets::notificationsWidget(['class' => 'col-sm-8 dashboard-wrapper'],'dashboard',__('Notifications')); \App\Widgets::teamWidgets(['class' => 'col-sm-4 dashboard-wrapper'],'dashboard',__('Planning de l\'équipe'));