gomagaming / logs
Register logs into GomaGaming Backend Service
Installs: 1 330
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- dev-master
- 0.0.41
- 0.0.40
- 0.0.39
- 0.0.38
- 0.0.37
- 0.0.36
- 0.0.35
- 0.0.34
- 0.0.33
- 0.0.32
- 0.0.31
- 0.0.30
- 0.0.29
- 0.0.28
- 0.0.27
- 0.0.26
- 0.0.25
- 0.0.24
- 0.0.23
- 0.0.22
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.18
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- dev-SPOR-1619-backend-sentry-logs
- dev-change_request
- dev-SPOR-1374-sports-data-crawler-sentry-archive-pending-issues
- dev-SPOR-1370-backend-investigation-jira-api
- dev-SPOR-1253-backend-sentry-issues-actions
- dev-add_getData_logJob
- dev-gomagaming-logs-api
- dev-SPOR-1119_delete_log_command
This package is auto-updated.
Last update: 2025-03-06 19:00:24 UTC
README
Description
- GomaGaming Logs tracks Exceptions, Requests and Responses and Custom logs and sends it to a specific queue with meta data associated (paths, parameters, headers, etc), which can then be properly treated.
Laravel Version Compatibility
- Laravel
>= 8.x.x
on PHP>= 7.3
Lumen Version Compatibility
- Lumen
>= 8.x.x
on PHP>= 7.3
Installation
composer require gomagaming/logs
Lumen Only
Add GomaGamingLogsServiceProvider to bootstrap/app.php:
$app->register(GomaGaming\Logs\GomaGamingLogsServiceProvider::class);
Configuration file
By default all logs are being sent to a queue called 'logs', but can be changed in config file gomagaminglogs.php
Lumen only:
cp vendor/gomagaming/logs/config/gomagaminglogs.php config/gomagaminglogs.php
Usage
Enable capturing unhandled exception by making the following change to App/Exceptions/Handler.php:
Laravel:
use GomaGaming\Logs\GomaGamingLogs;
public function register()
{
$this->reportable(function (Throwable $e) {
if ($this->shouldReport($e)) {
GomaGamingLogs::error($e->getMessage());
}
});
}
Lumen:
use GomaGaming\Logs\GomaGamingLogs;
public function report(Throwable $exception)
{
if ($this->shouldReport($exception)) {
GomaGamingLogs::error($exception->getMessage());
}
parent::report($exception);
}
To capture information about all incoming requests or all responses, add the following middleware as global or apply it to a group:
In Laravel add it to app/Http/Kernel.php:
protected $middleware = [
(...)
\GomaGaming\Logs\Http\Middleware\LogRequests::class,
\GomaGaming\Logs\Http\Middleware\LogResponses::class,
];
In Lumen add it to bootstarp/app.php:
$app->middleware([
\GomaGaming\Logs\Http\Middleware\LogRequests::class,
\GomaGaming\Logs\Http\Middleware\LogResponses::class
]);
Custom errors or informations can also be reported:
use GomaGaming\Logs\GomaGamingLogs;
GomaGamingLogs::info("This is an information about my service.");
GomaGamingLogs::error("This is an error ocurring in my service");
For API's that don't want to give users information about exceptions, we can change render method in App/Exceptions/Handler.php to return always http code 500 with a custom message, example:
public function render($request, Throwable $exception)
{
(...)
//might want to check if request is asking for json response
return response()->json(['status' => 'error', 'msg' => 'Internal Server Error'], 500);
}
TODO
Tests