Replace references to log service.

This commit is contained in:
James Cole
2025-11-02 14:45:39 +01:00
parent b49575db8b
commit ae767fc90d
6 changed files with 81 additions and 76 deletions

View File

@@ -29,6 +29,7 @@ use FireflyIII\Notifications\User\NewAccessToken;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\Notification;
use Laravel\Passport\Events\AccessTokenCreated;
use Illuminate\Support\Facades\Log;
/**
* Class APIEventHandler
@@ -40,7 +41,7 @@ class APIEventHandler
*/
public function accessTokenCreated(AccessTokenCreated $event): void
{
app('log')->debug(__METHOD__);
Log::debug(__METHOD__);
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
@@ -52,17 +53,17 @@ class APIEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
}

View File

@@ -38,6 +38,7 @@ use FireflyIII\Notifications\Test\OwnerTestNotificationSlack;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
/**
* Class AdminEventHandler.
*/
@@ -55,17 +56,17 @@ class AdminEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
@@ -77,17 +78,17 @@ class AdminEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
@@ -107,17 +108,17 @@ class AdminEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
@@ -150,7 +151,7 @@ class AdminEventHandler
break;
default:
app('log')->error(sprintf('Unknown channel "%s" in sendTestNotification method.', $event->channel));
Log::error(sprintf('Unknown channel "%s" in sendTestNotification method.', $event->channel));
return;
}
@@ -161,17 +162,17 @@ class AdminEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));
}

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Handlers\Events;
use Carbon\Carbon;
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Repositories\AuditLogEntry\ALERepositoryInterface;
use Illuminate\Support\Facades\Log;
/**
* Class AuditEventHandler
@@ -44,20 +45,20 @@ class AuditEventHandler
];
if ($event->before === $event->after) {
app('log')->debug('Will not store event log because before and after are the same.');
Log::debug('Will not store event log because before and after are the same.');
return;
}
if ($event->before instanceof Carbon && $event->after instanceof Carbon && $event->before->eq($event->after)) {
app('log')->debug('Will not store event log because before and after Carbon values are the same.');
Log::debug('Will not store event log because before and after Carbon values are the same.');
return;
}
if ($event->before instanceof Carbon && $event->after instanceof Carbon) {
$array['before'] = $event->before->toIso8601String();
$array['after'] = $event->after->toIso8601String();
app('log')->debug(sprintf('Converted "before" to "%s".', $event->before));
app('log')->debug(sprintf('Converted "after" to "%s".', $event->after));
Log::debug(sprintf('Converted "before" to "%s".', $event->before));
Log::debug(sprintf('Converted "after" to "%s".', $event->after));
}
/** @var ALERepositoryInterface $repository */

View File

@@ -33,6 +33,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\Transformers\TransactionGroupTransformer;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Log;
/**
* Class AutomationHandler
@@ -46,7 +47,7 @@ class AutomationHandler
*/
public function reportJournals(RequestedReportOnJournals $event): void
{
app('log')->debug('In reportJournals.');
Log::debug('In reportJournals.');
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
@@ -56,17 +57,17 @@ class AutomationHandler
$sendReport = Preferences::getForUser($user, 'notification_transaction_creation', false)->data;
if (false === $sendReport) {
app('log')->debug('Not sending report, because config says so.');
Log::debug('Not sending report, because config says so.');
return;
}
if (null === $user || 0 === $event->groups->count()) {
app('log')->debug('No transaction groups in event, nothing to email about.');
Log::debug('No transaction groups in event, nothing to email about.');
return;
}
app('log')->debug('Continue with message!');
Log::debug('Continue with message!');
// transform groups into array:
/** @var TransactionGroupTransformer $transformer */
@@ -83,18 +84,18 @@ class AutomationHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
app('log')->debug('If there is no error above this line, message was sent.');
Log::debug('If there is no error above this line, message was sent.');
}
}

View File

@@ -45,7 +45,7 @@ class DestroyedGroupEventHandler
private function triggerWebhooks(DestroyedTransactionGroup $destroyedGroupEvent): void
{
app('log')->debug('DestroyedTransactionGroup:triggerWebhooks');
Log::debug('DestroyedTransactionGroup:triggerWebhooks');
$group = $destroyedGroupEvent->transactionGroup;
$user = $group->user;

View File

@@ -58,6 +58,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
/**
* Class UserEventHandler.
*
@@ -77,7 +78,7 @@ class UserEventHandler
// first user ever?
if (1 === $repository->count()) {
app('log')->debug('User count is one, attach role.');
Log::debug('User count is one, attach role.');
$repository->attachRole($event->user, 'owner');
}
}
@@ -101,10 +102,10 @@ class UserEventHandler
if (null === $role) {
// create role, does not exist. Very strange situation so let's raise a big fuss about it.
$role = $repository->createRole('owner', 'Site Owner', 'User runs this instance of FF3');
app('log')->error('Could not find role "owner". This is weird.');
Log::error('Could not find role "owner". This is weird.');
}
app('log')->info(sprintf('Gave user #%d role #%d ("%s")', $user->id, $role->id, $role->name));
Log::info(sprintf('Gave user #%d role #%d ("%s")', $user->id, $role->id, $role->name));
// give user the role
$repository->attachRole($user, 'owner');
}
@@ -203,17 +204,17 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
$list[$index]['notified'] = true;
@@ -233,17 +234,17 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
}
@@ -265,8 +266,8 @@ class UserEventHandler
try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
} catch (Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage(), 0, $e);
}
@@ -290,8 +291,8 @@ class UserEventHandler
try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
} catch (Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage(), 0, $e);
}
@@ -304,17 +305,17 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
@@ -328,17 +329,17 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
@@ -354,8 +355,8 @@ class UserEventHandler
try {
Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
} catch (Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage(), 0, $e);
}
@@ -374,17 +375,17 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
}
}
@@ -418,7 +419,7 @@ class UserEventHandler
break;
default:
app('log')->error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));
Log::error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));
return;
}
@@ -429,28 +430,28 @@ class UserEventHandler
} catch (Exception $e) {
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
if (str_contains($message, 'RFC 2822')) {
app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
Log::warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
return;
}
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));
}
public function storeUserIPAddress(ActuallyLoggedIn $event): void
{
app('log')->debug('Now in storeUserIPAddress');
Log::debug('Now in storeUserIPAddress');
$user = $event->user;
if ($user->hasRole('demo')) {
app('log')->debug('Do not log demo user logins');
Log::debug('Do not log demo user logins');
return;
}
@@ -460,25 +461,25 @@ class UserEventHandler
$preference = Preferences::getForUser($user, 'login_ip_history', [])->data;
} catch (FireflyException $e) {
// don't care.
app('log')->error($e->getMessage());
Log::error($e->getMessage());
return;
}
$inArray = false;
$ip = request()->ip();
app('log')->debug(sprintf('User logging in from IP address %s', $ip));
Log::debug(sprintf('User logging in from IP address %s', $ip));
// update array if in array
foreach ($preference as $index => $row) {
if ($row['ip'] === $ip) {
app('log')->debug('Found IP in array, refresh time.');
Log::debug('Found IP in array, refresh time.');
$preference[$index]['time'] = now(config('app.timezone'))->format('Y-m-d H:i:s');
$inArray = true;
}
// clean up old entries (6 months)
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
if ($carbon instanceof Carbon && $carbon->diffInMonths(today(), true) > 6) {
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
Log::debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
unset($preference[$index]);
}
}