Fix FLEXIAPI-358 Write all the logs to syslog (and by extension journald)

This commit is contained in:
Timothée Jaussoin 2026-01-27 11:50:14 +01:00
parent 6550a9082c
commit 117965cb8c
18 changed files with 50 additions and 105 deletions

View file

@ -46,11 +46,11 @@ class PasswordController extends Controller
$account->updatePassword($request->get('password')); $account->updatePassword($request->get('password'));
if ($account->passwords()->count() > 0) { if ($account->passwords()->count() > 0) {
Log::channel('events')->info('Web: Password changed', ['id' => $account->identifier]); Log::info('Web: Password changed', ['id' => $account->identifier]);
return redirect()->route('account.logout'); return redirect()->route('account.logout');
} }
Log::channel('events')->info('Web: Password set for the first time', ['id' => $account->identifier]); Log::info('Web: Password set for the first time', ['id' => $account->identifier]);
return redirect()->route('account.logout'); return redirect()->route('account.logout');
} }
} }

View file

@ -53,7 +53,7 @@ class AccountTypeController extends Controller
$account->types()->detach($request->get('account_type_id')); $account->types()->detach($request->get('account_type_id'));
$account->types()->attach($request->get('account_type_id')); $account->types()->attach($request->get('account_type_id'));
Log::channel('events')->info('Web Admin: Account type attached', ['id' => $account->identifier, 'type_id' => $request->get('account_type_id')]); Log::info('Web Admin: Account type attached', ['id' => $account->identifier, 'type_id' => $request->get('account_type_id')]);
return redirect()->route('admin.account.show', $account)->withFragment('#types'); return redirect()->route('admin.account.show', $account)->withFragment('#types');
} }
@ -64,7 +64,7 @@ class AccountTypeController extends Controller
$account->types()->detach($typeId); $account->types()->detach($typeId);
Log::channel('events')->info('Web Admin: Account type detached', ['id' => $account->identifier, 'type_id' => $request->get('account_type_id')]); Log::info('Web Admin: Account type detached', ['id' => $account->identifier, 'type_id' => $request->get('account_type_id')]);
return redirect()->route('admin.account.show', $account)->withFragment('#types'); return redirect()->route('admin.account.show', $account)->withFragment('#types');
} }

View file

@ -54,7 +54,7 @@ class ActionController extends Controller
$accountAction->code = $request->get('code'); $accountAction->code = $request->get('code');
$accountAction->save(); $accountAction->save();
Log::channel('events')->info('Web Admin: Account action created', ['id' => $account->identifier, 'action' => $accountAction->key]); Log::info('Web Admin: Account action created', ['id' => $account->identifier, 'action' => $accountAction->key]);
return redirect()->route('admin.account.show', $accountAction->account)->withFragment('#actions'); return redirect()->route('admin.account.show', $accountAction->account)->withFragment('#actions');
} }
@ -89,7 +89,7 @@ class ActionController extends Controller
$accountAction->code = $request->get('code'); $accountAction->code = $request->get('code');
$accountAction->save(); $accountAction->save();
Log::channel('events')->info('Web Admin: Account action updated', ['id' => $account->identifier, 'action' => $accountAction->key]); Log::info('Web Admin: Account action updated', ['id' => $account->identifier, 'action' => $accountAction->key]);
return redirect()->route('admin.account.show', $account)->withFragment('#actions'); return redirect()->route('admin.account.show', $account)->withFragment('#actions');
} }
@ -115,7 +115,7 @@ class ActionController extends Controller
->firstOrFail(); ->firstOrFail();
$accountAction->delete(); $accountAction->delete();
Log::channel('events')->info('Web Admin: Account action deleted', ['id' => $accountAction->account->identifier, 'action_id' => $accountAction->key]); Log::info('Web Admin: Account action deleted', ['id' => $accountAction->account->identifier, 'action_id' => $accountAction->key]);
return redirect()->route('admin.account.show', $accountAction->account)->withFragment('#actions'); return redirect()->route('admin.account.show', $accountAction->account)->withFragment('#actions');
} }

View file

@ -69,7 +69,7 @@ class ContactController extends Controller
$account->contacts()->detach($contact->id); $account->contacts()->detach($contact->id);
$account->contacts()->attach($contact->id); $account->contacts()->attach($contact->id);
Log::channel('events')->info('Web Admin: Account contact added', ['id' => $account->identifier, 'contact' => $contact->identifier]); Log::info('Web Admin: Account contact added', ['id' => $account->identifier, 'contact' => $contact->identifier]);
return redirect()->route('admin.account.contact.index', $account); return redirect()->route('admin.account.contact.index', $account);
} }
@ -92,7 +92,7 @@ class ContactController extends Controller
$account->contacts()->detach($contact->id); $account->contacts()->detach($contact->id);
Log::channel('events')->info('Web Admin: Account contact removed', ['id' => $account->identifier, 'contact' => $contact->identifier]); Log::info('Web Admin: Account contact removed', ['id' => $account->identifier, 'contact' => $contact->identifier]);
return redirect()->route('admin.account.contact.index', $account); return redirect()->route('admin.account.contact.index', $account);
} }

View file

@ -91,7 +91,7 @@ class TypeController extends Controller
$type = AccountType::findOrFail($typeId); $type = AccountType::findOrFail($typeId);
$type->delete(); $type->delete();
Log::channel('events')->info('Web Admin: Account type deleted', ['type' => $type->key]); Log::info('Web Admin: Account type deleted', ['type' => $type->key]);
return redirect()->route('admin.account.type.index'); return redirect()->route('admin.account.type.index');
} }

View file

@ -110,7 +110,7 @@ class AccountController extends Controller
{ {
$account = (new AccountService)->store($request); $account = (new AccountService)->store($request);
Log::channel('events')->info('Web Admin: Account created', ['id' => $account->identifier]); Log::info('Web Admin: Account created', ['id' => $account->identifier]);
return redirect()->route('admin.account.show', $account); return redirect()->route('admin.account.show', $account);
} }
@ -132,7 +132,7 @@ class AccountController extends Controller
{ {
$account = (new AccountService)->update($request, $accountId); $account = (new AccountService)->update($request, $accountId);
Log::channel('events')->info('Web Admin: Account updated', ['id' => $account->identifier]); Log::info('Web Admin: Account updated', ['id' => $account->identifier]);
return redirect()->route('admin.account.show', $accountId); return redirect()->route('admin.account.show', $accountId);
} }
@ -143,7 +143,7 @@ class AccountController extends Controller
$account->provision(); $account->provision();
$account->save(); $account->save();
Log::channel('events')->info('Web Admin: Account provisioned', ['id' => $account->identifier]); Log::info('Web Admin: Account provisioned', ['id' => $account->identifier]);
return redirect()->back()->withFragment('provisioning'); return redirect()->back()->withFragment('provisioning');
} }
@ -163,7 +163,7 @@ class AccountController extends Controller
(new AccountService)->destroy($request, $request->get('account_id')); (new AccountService)->destroy($request, $request->get('account_id'));
Log::channel('events')->info('Web Admin: Account deleted', ['id' => $account->identifier]); Log::info('Web Admin: Account deleted', ['id' => $account->identifier]);
return redirect()->route('admin.account.index'); return redirect()->route('admin.account.index');
} }

View file

@ -29,7 +29,7 @@ class ProvisioningEmailController extends Controller
Mail::to($account)->send(new Provisioning($account)); Mail::to($account)->send(new Provisioning($account));
Log::channel('events')->info('Web Admin: Sending provisioning email', ['id' => $account->identifier]); Log::info('Web Admin: Sending provisioning email', ['id' => $account->identifier]);
return redirect()->route('admin.account.show', $account); return redirect()->route('admin.account.show', $account);
} }

View file

@ -82,7 +82,7 @@ class AccountController extends Controller
$account->provision(); $account->provision();
$account->save(); $account->save();
Log::channel('events')->info('API: Account provisioned', ['id' => $account->identifier]); Log::info('API: Account provisioned', ['id' => $account->identifier]);
return $account->makeVisible(['provisioning_token']); return $account->makeVisible(['provisioning_token']);
} }

View file

@ -53,7 +53,7 @@ class CreationTokenController extends Controller
->first(); ->first();
if ($last) { if ($last) {
Log::channel('events')->info('API: Token throttled', ['token' => $last->token]); Log::info('API: Token throttled', ['token' => $last->token]);
abort(429, 'Last token requested too recently'); abort(429, 'Last token requested too recently');
} }
@ -66,7 +66,7 @@ class CreationTokenController extends Controller
$fp = new FlexisipPusherConnector($token->pn_provider, $token->pn_param, $token->pn_prid); $fp = new FlexisipPusherConnector($token->pn_provider, $token->pn_param, $token->pn_prid);
if ($fp->sendToken($token->token)) { if ($fp->sendToken($token->token)) {
Log::channel('events')->info('API: Account Creation Token sent', ['token' => $token->token]); Log::info('API: Account Creation Token sent', ['token' => $token->token]);
$token->save(); $token->save();
return; return;

View file

@ -50,7 +50,7 @@ class PasswordController extends Controller
)) { )) {
$account->updatePassword($request->get('password'), $algorithm); $account->updatePassword($request->get('password'), $algorithm);
Log::channel('events')->info('API: Account password updated', ['id' => $account->identifier]); Log::info('API: Account password updated', ['id' => $account->identifier]);
return response()->json(); return response()->json();
} }

View file

@ -27,7 +27,7 @@ class PushNotificationController extends Controller
$fp = new FlexisipPusherConnector($request->get('pn_provider'), $request->get('pn_param'), $request->get('pn_prid')); $fp = new FlexisipPusherConnector($request->get('pn_provider'), $request->get('pn_param'), $request->get('pn_prid'));
if ($fp->send(callId: $request->get('call_id'), type: $request->get('type'))) { if ($fp->send(callId: $request->get('call_id'), type: $request->get('type'))) {
Log::channel('events')->info('API: Push notification sent', [ Log::info('API: Push notification sent', [
'call_id' => $request->get('call_id'), 'call_id' => $request->get('call_id'),
'type' => $request->get('type') 'type' => $request->get('type')
]); ]);

View file

@ -51,7 +51,7 @@ class RecoveryTokenController extends Controller
->first(); ->first();
if ($last) { if ($last) {
Log::channel('events')->info('API: Token throttled', ['token' => $last->token]); Log::info('API: Token throttled', ['token' => $last->token]);
abort(429, 'Last token requested too recently'); abort(429, 'Last token requested too recently');
} }
@ -64,7 +64,7 @@ class RecoveryTokenController extends Controller
$fp = new FlexisipPusherConnector($token->pn_provider, $token->pn_param, $token->pn_prid); $fp = new FlexisipPusherConnector($token->pn_provider, $token->pn_param, $token->pn_prid);
if ($fp->sendToken($token->token)) { if ($fp->sendToken($token->token)) {
Log::channel('events')->info('API: AccountRecoveryToken sent', ['token' => $token->token]); Log::info('API: AccountRecoveryToken sent', ['token' => $token->token]);
$token->save(); $token->save();
return; return;

View file

@ -98,7 +98,7 @@ class AccountController extends Controller
(new AccountService())->destroy($request, $accountId); (new AccountService())->destroy($request, $accountId);
Log::channel('events')->info('API Admin: Account destroyed', ['id' => $account->identifier]); Log::info('API Admin: Account destroyed', ['id' => $account->identifier]);
} }
public function activate(Request $request, int $accountId) public function activate(Request $request, int $accountId)
@ -107,7 +107,7 @@ class AccountController extends Controller
$account->activated = true; $account->activated = true;
$account->save(); $account->save();
Log::channel('events')->info('API Admin: Account activated', ['id' => $account->identifier]); Log::info('API Admin: Account activated', ['id' => $account->identifier]);
return $account; return $account;
} }
@ -118,7 +118,7 @@ class AccountController extends Controller
$account->activated = false; $account->activated = false;
$account->save(); $account->save();
Log::channel('events')->info('API Admin: Account deactivated', ['id' => $account->identifier]); Log::info('API Admin: Account deactivated', ['id' => $account->identifier]);
return $account; return $account;
} }
@ -129,7 +129,7 @@ class AccountController extends Controller
$account->blocked = true; $account->blocked = true;
$account->save(); $account->save();
Log::channel('events')->info('API Admin: Account blocked', ['id' => $account->identifier]); Log::info('API Admin: Account blocked', ['id' => $account->identifier]);
return $account; return $account;
} }
@ -140,7 +140,7 @@ class AccountController extends Controller
$account->blocked = false; $account->blocked = false;
$account->save(); $account->save();
Log::channel('events')->info('API Admin: Account unblocked', ['id' => $account->identifier]); Log::info('API Admin: Account unblocked', ['id' => $account->identifier]);
return $account; return $account;
} }
@ -151,7 +151,7 @@ class AccountController extends Controller
$account->provision(); $account->provision();
$account->save(); $account->save();
Log::channel('events')->info('API Admin: Account provisioned', ['id' => $account->identifier]); Log::info('API Admin: Account provisioned', ['id' => $account->identifier]);
return $account->makeVisible(['provisioning_token']); return $account->makeVisible(['provisioning_token']);
} }
@ -165,7 +165,7 @@ class AccountController extends Controller
{ {
$account = (new AccountService())->update($request, $accountId); $account = (new AccountService())->update($request, $accountId);
Log::channel('events')->info('API Admin: Account updated', ['id' => $account->identifier]); Log::info('API Admin: Account updated', ['id' => $account->identifier]);
return $account->makeVisible(['provisioning_token']); return $account->makeVisible(['provisioning_token']);
} }
@ -225,7 +225,7 @@ class AccountController extends Controller
Mail::to($account)->send(new Provisioning($account)); Mail::to($account)->send(new Provisioning($account));
Log::channel('events')->info('API: Sending provisioning email', ['id' => $account->identifier]); Log::info('API: Sending provisioning email', ['id' => $account->identifier]);
} }
public function sendResetPasswordEmail(Request $request, int $accountId) public function sendResetPasswordEmail(Request $request, int $accountId)

View file

@ -49,7 +49,7 @@ class StatisticsCallController extends Controller
try { try {
return $statisticsCall->saveOrFail(); return $statisticsCall->saveOrFail();
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('database_errors')->error($e->getMessage()); Log::error($e->getMessage());
abort(400, 'Database error'); abort(400, 'Database error');
} }
} }
@ -72,7 +72,7 @@ class StatisticsCallController extends Controller
] ]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('database_errors')->error($e->getMessage()); Log::error($e->getMessage());
abort(400, 'Database error'); abort(400, 'Database error');
} }
} }

View file

@ -47,7 +47,7 @@ class StatisticsMessageController extends Controller
try { try {
return $statisticsMessage->saveOrFail(); return $statisticsMessage->saveOrFail();
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('database_errors')->error($e->getMessage()); Log::error($e->getMessage());
abort(400, 'Database error'); abort(400, 'Database error');
} }
} }
@ -68,7 +68,7 @@ class StatisticsMessageController extends Controller
['last_status' => $request->get('last_status'), 'received_at' => $request->get('received_at')] ['last_status' => $request->get('last_status'), 'received_at' => $request->get('received_at')]
); );
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('database_errors')->error($e->getMessage()); Log::error($e->getMessage());
abort(400, 'Database error'); abort(400, 'Database error');
} }
} }

View file

@ -47,7 +47,7 @@ class OvhSMS
$this->smsService = $smsServices[0]; $this->smsService = $smsServices[0];
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('events')->info('OVH SMS API unreachable, check the errors log'); Log::info('OVH SMS API unreachable, check the errors log');
Log::error('OVH SMS API not reachable: ' . $e->getMessage()); Log::error('OVH SMS API not reachable: ' . $e->getMessage());
} }
} }
@ -72,7 +72,7 @@ class OvhSMS
'validityPeriod' => 2880 'validityPeriod' => 2880
]; ];
Log::channel('events')->info('OVH SMS sending', ['to' => $to, 'message' => $message]); Log::info('OVH SMS sending', ['to' => $to, 'message' => $message]);
try { try {
$this->api->post('/sms/'. $this->smsService . '/jobs', $content); $this->api->post('/sms/'. $this->smsService . '/jobs', $content);
@ -80,7 +80,7 @@ class OvhSMS
$this->api->get('/sms/'. $this->smsService . '/jobs'); $this->api->get('/sms/'. $this->smsService . '/jobs');
} catch (\Exception $e) { } catch (\Exception $e) {
Log::channel('events')->info('OVH SMS not sent, check the errors log'); Log::info('OVH SMS not sent, check the errors log');
Log::error('OVH SMS not sent: ' . $e->getMessage()); Log::error('OVH SMS not sent: ' . $e->getMessage());
} }
} }

View file

@ -102,10 +102,10 @@ class AccountService
$token->account_id = $account->id; $token->account_id = $account->id;
$token->save(); $token->save();
Log::channel('events')->info('API: AccountCreationToken redeemed', ['account_creation_token' => $token->toLog()]); Log::info('API: AccountCreationToken redeemed', ['account_creation_token' => $token->toLog()]);
} }
Log::channel('events')->info( Log::info(
$request->asAdmin $request->asAdmin
? 'Account Service as Admin: Account created' ? 'Account Service as Admin: Account created'
: 'Account Service: Account created', : 'Account Service: Account created',
@ -176,7 +176,7 @@ class AccountService
} }
} }
Log::channel('events')->info( Log::info(
$request->asAdmin $request->asAdmin
? 'Account Service as Admin: Account updated' ? 'Account Service as Admin: Account updated'
: 'Account Service: Account updated', : 'Account Service: Account updated',
@ -206,7 +206,7 @@ class AccountService
(new FlexisipRedisConnector)->pingB2BUA($externalAccount); (new FlexisipRedisConnector)->pingB2BUA($externalAccount);
} }
Log::channel('events')->info( Log::info(
'Account Service: Account destroyed', 'Account Service: Account destroyed',
['id' => $account->identifier] ['id' => $account->identifier]
); );
@ -239,7 +239,7 @@ class AccountService
$phoneChangeCode->fillRequestInfo($request); $phoneChangeCode->fillRequestInfo($request);
$phoneChangeCode->save(); $phoneChangeCode->save();
Log::channel('events')->info('Account Service: Account phone change requested by SMS', ['id' => $account->identifier]); Log::info('Account Service: Account phone change requested by SMS', ['id' => $account->identifier]);
$message = 'Your ' . $account->space->name . ' validation code is ' . $phoneChangeCode->code . '.'; $message = 'Your ' . $account->space->name . ' validation code is ' . $phoneChangeCode->code . '.';
@ -278,7 +278,7 @@ class AccountService
$account->activated = true; $account->activated = true;
$account->save(); $account->save();
Log::channel('events')->info('Account Service: Account phone changed using SMS', ['id' => $account->identifier]); Log::info('Account Service: Account phone changed using SMS', ['id' => $account->identifier]);
$account->refresh(); $account->refresh();
@ -318,7 +318,7 @@ class AccountService
$emailChangeCode->fillRequestInfo($request); $emailChangeCode->fillRequestInfo($request);
$emailChangeCode->save(); $emailChangeCode->save();
Log::channel('events')->info('Account Service: Account email change requested by email', ['id' => $account->identifier]); Log::info('Account Service: Account email change requested by email', ['id' => $account->identifier]);
Mail::to($emailChangeCode->email)->send(new RegisterValidation($account)); Mail::to($emailChangeCode->email)->send(new RegisterValidation($account));
} }
@ -349,7 +349,7 @@ class AccountService
$account->email = $emailChangeCode->email; $account->email = $emailChangeCode->email;
$account->save(); $account->save();
Log::channel('events')->info('Account Service: Account email changed using email', ['id' => $account->identifier]); Log::info('Account Service: Account email changed using email', ['id' => $account->identifier]);
$emailChangeCode->consume(); $emailChangeCode->consume();
@ -380,7 +380,7 @@ class AccountService
Mail::to($account)->send(new RecoverByCode($account)); Mail::to($account)->send(new RecoverByCode($account));
Log::channel('events')->info('Account Service: Sending recovery email', ['id' => $account->identifier]); Log::info('Account Service: Sending recovery email', ['id' => $account->identifier]);
return $account; return $account;
} }
@ -400,13 +400,13 @@ class AccountService
$ovhSMS = new OvhSMS(); $ovhSMS = new OvhSMS();
$ovhSMS->send($account->phone, $message); $ovhSMS->send($account->phone, $message);
Log::channel('events')->info('Account Service: Sending recovery SMS', ['id' => $account->identifier]); Log::info('Account Service: Sending recovery SMS', ['id' => $account->identifier]);
$accountRecoveryToken->consume(); $accountRecoveryToken->consume();
$accountRecoveryToken->account_id = $account->id; $accountRecoveryToken->account_id = $account->id;
$accountRecoveryToken->save(); $accountRecoveryToken->save();
Log::channel('events')->info('API: AccountRecoveryToken redeemed', ['account_recovery_token' => $accountRecoveryToken->toLog()]); Log::info('API: AccountRecoveryToken redeemed', ['account_recovery_token' => $accountRecoveryToken->toLog()]);
return $account; return $account;
} }

View file

@ -35,57 +35,12 @@ return [
*/ */
'channels' => [ 'channels' => [
'events' => [
'driver' => 'daily',
'path' => storage_path('logs/events.log'),
'level' => 'info',
'days' => 30
],
'database_errors' => [
'driver' => 'daily',
'path' => storage_path('logs/database_errors.log'),
'level' => 'error',
'days' => 30
],
'stack' => [ 'stack' => [
'driver' => 'stack', 'driver' => 'syslog',
'channels' => ['single'], 'level' => 'debug',
'ignore_exceptions' => false, 'ignore_exceptions' => false,
], ],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
'port' => env('PAPERTRAIL_PORT'),
],
],
'stderr' => [ 'stderr' => [
'driver' => 'monolog', 'driver' => 'monolog',
'handler' => StreamHandler::class, 'handler' => StreamHandler::class,
@ -99,16 +54,6 @@ return [
'driver' => 'syslog', 'driver' => 'syslog',
'level' => 'debug', 'level' => 'debug',
], ],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
], ],
]; ];