Skip to content

Commit 9c8ef24

Browse files
authored
Merge pull request #42 from MRR-Group/logs
add logs
2 parents 0ccf499 + 4f795bd commit 9c8ef24

File tree

8 files changed

+31
-0
lines changed

8 files changed

+31
-0
lines changed

app/Http/Controllers/InviteController.php

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use App\Models\Invite;
1616
use App\Models\User;
1717
use Illuminate\Http\Request;
18+
use Illuminate\Support\Facades\Log;
1819
use Illuminate\Support\Facades\Mail;
1920
use Illuminate\Support\Facades\Redirect;
2021
use Inertia\Inertia;
@@ -41,6 +42,7 @@ public function send_invite(int $user_id, int $game_id, Request $request)
4142
$invite->save();
4243

4344
Mail::to($invite->receiver->email)->send(new InviteReceivedNotification($invite));
45+
Log::channel('invites')->info('Sent invite from user ' . $invite->sender->id . ' to ' . $invite->receiver->id . '. Game: ' . $game->name);
4446

4547
return Redirect::route("invite.show")->with("status", "Request sent to " . $target_user->name);
4648
}
@@ -102,6 +104,7 @@ public function update(InviteUpdateRequest $request, int $id)
102104
$invite->save();
103105

104106
$status = $invite->is_accepted ? "accepted" : "rejected";
107+
Log::channel('invites')->info('Updated invite from user ' . $invite->sender->id . ' to ' . $invite->receiver->id . ' game: ' . $invite->game->name . ' status: ' . $status);
105108

106109
if ($invite->is_accepted) {
107110
Mail::to($invite->sender->email)->send(new InviteAcceptedNotification($invite));
@@ -118,7 +121,9 @@ public function remove(int $id)
118121
throw new InviteNotFoundException();
119122
}
120123

124+
Log::channel('invites')->info('Deleted invite from user ' . $invite->sender->id . ' to ' . $invite->receiver->id . ' game: ' . $invite->game->name);
121125
$invite->delete();
126+
122127

123128
return Redirect::route("invite.show")->with("status", "Deleted invite from " . $invite->sender->name);
124129
}

app/Models/User.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Notifications\Notifiable;
1212
use Illuminate\Support\Carbon;
1313
use Illuminate\Support\Collection;
14+
use Illuminate\Support\Facades\Log;
1415

1516
/**
1617
* @property int $id
@@ -62,6 +63,8 @@ public function load_steam_data(string $steam_id, string $nickname, string $avat
6263
$this->name = $nickname;
6364
$this->image = $this->load_bigger_image($avatar);
6465
$this->save();
66+
67+
Log::channel('steam')->info('Connected steam_id ' . $steam_id . ' with user ' . $this->id);
6568
}
6669

6770
public function json_games(): array

app/Services/Matching/MatchingService.php

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Services\Matching;
66

77
use App\Models\Game;
8+
use Illuminate\Support\Facades\Log;
89

910
class MatchingService
1011
{
@@ -22,6 +23,7 @@ public function find_candidates(Game $user_game)
2223
}
2324

2425
usort($mates, fn($a, $b) => $a["delta_play_time"] - $b["delta_play_time"]);
26+
Log::channel('invites')->info('Searching players for game ' . $user_game->id . ' found: ' . count($mates) . ' candidates');
2527

2628
return $mates;
2729
}

app/Services/Steam/SteamService.php

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Carbon\Carbon;
1717
use Illuminate\Bus\Batch;
1818
use Illuminate\Support\Facades\Bus;
19+
use Illuminate\Support\Facades\Log;
1920
use Illuminate\Support\Facades\Mail;
2021

2122
class SteamService
@@ -35,10 +36,14 @@ public function fetch_games(User $user): Batch
3536
}
3637

3738
return Bus::batch($jobs)
39+
->before(function () use ($user): void {
40+
Log::channel('steam')->info('Start fetching steam data for ' . $user->email);
41+
})
3842
->then(function () use ($user): void {
3943
$user->last_fetch = Carbon::now();
4044
$user->save();
4145

46+
Log::channel('steam')->info('Done fetching steam data for ' . $user->email);
4247
Mail::to($user->email)->send(new SteamFetchedNotification($user));
4348
})->dispatch();
4449
}

config/logging.php

+12
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,17 @@
126126
"emergency" => [
127127
"path" => storage_path("logs/laravel.log"),
128128
],
129+
130+
"invites" => [
131+
'driver' => 'single',
132+
'path' => storage_path('logs/invites.log'),
133+
'level' => 'debug'
134+
],
135+
136+
"steam" => [
137+
'driver' => 'single',
138+
'path' => storage_path('logs/steam.log'),
139+
'level' => 'debug'
140+
],
129141
],
130142
];

lang/php_en.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"app.Games":"Games","app.Profile":"Profile","app.Invites":"Invites","app.Log out":"Log out","app.Edit":"Edit","app.Search":"Search","app.Polish Version":"Wersja Polska","app.Library":"Library","app.Search game":"Search game","app.Search games with tag":"Search games with :name tag","app.Game Details":"Game Details","app.Find Mate":"Find Mate","app.Achievements":"Achievements","app.Icon for the achievement":"Icon for the \":name\\\" achievement","app.statistics":":game statistics","app.Statistics":"Statistics","app.user's":":name's","app.Play Time":"Play time","app.Game Completion":"Game completion","app.Similar achievements":"Similar achievements","app.Cover image of the game":"Cover image of the :game game","app.Blurred cover image of the game":"Blurred cover image of the :game game","app.Sent Invites":"Sent Invites","app.Received Invites":"Received Invites","app.Accepted Invites":"Accepted Invites","app.Profile image of user":"Profile image of :name","app.Accept":"Accept","app.Reject":"Reject","app.Remove":"Remove","app.Status":"Status","app.accepted":"accepted","app.rejected":"rejected","app.pending":"pending","app.No matches found for":"No matches found for :name","app.You are the only user message":"It looks like you're the only one with :name in your library! Unfortunately, no one else has it in their collection at the moment. You might want to check out other games or try searching again later.","app.Back":"Back","app.Next":"Next","app.Previous":"Previous","app.Check other games":"Check other games","app.See Profile":"Go to Profile","app.Send Invite":"Send Invite","app.Remove tag - search query":"Remove :name tag from the search query","app.Add tag - search query":"Add :name tag to the search query","app.Name":"Name","app.Description":"Description","app.Save":"Save","app.Navigate to user statistics for the game":"Navigate to :user statistics for the game \":game\\\"","app.Close":"Close","app.games":"games","app.Left":"Left","app.Right":"Right","app.Matching":"Matching","auth-layout.log in":"Log in","auth-layout.log in title":"Log in","auth-layout.register":"Register","auth-layout.register title":"Register","auth-layout.reset password title":"Reset Password","auth-layout.email verification title":"Email Verification","auth-layout.connect steam title":"Connect Steam","auth-layout.email":"Email","auth-layout.password":"Password","auth-layout.confirm password":"Confirm Password","auth-layout.reset password":"Reset Password","auth-layout.send":"Send","auth-layout.connect":"Connect","auth-layout.fetch":"Fetch","auth-layout.processing":"processing","auth-layout.Connect your steam account":"Connect your steam account","auth-layout.You don't have an account?":"You don't have an account?","auth-layout.You don't remember?":"You don't remember?","auth-layout.Do you remember your password?":"Do you remember your password?","auth-layout.Do you have an account?":"Do you have an account?","auth-layout.You don't want to do it right now?":"You don't want to do it right now?","auth-layout.Click":"Click","auth-layout.here":"here","auth-layout.to":"to","auth-layout.to register":"register","auth-layout.to reset it.":"reset it.","auth-layout.to log in.":"log in.","auth-layout.to log out.":"log out.","auth-layout.verification-link-sent":"A new verification link has been sent to the email address you provided during registration.","auth-layout.email verification message":"Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn't receive the email, we will gladly send you another.","auth-layout.resend verification email":"Resend Verification Email","auth-layout.this is the last step":"This is the last step","auth-layout.fetch message":"Now we need to download from steam information about all your achievements and games. It may take a while.","auth.failed":"These credentials do not match our records.","auth.password":"The provided password is incorrect.","auth.throttle":"Too many login attempts. Please try again in :seconds seconds.","pagination.previous":"« Previous","pagination.next":"Next »","passwords.reset":"Your password has been reset.","passwords.sent":"We have emailed your password reset link.","passwords.throttled":"Please wait before retrying.","passwords.token":"This password reset token is invalid.","passwords.user":"We can't find a user with that email address.","validation.accepted":"The :attribute field must be accepted.","validation.accepted_if":"The :attribute field must be accepted when :other is :value.","validation.active_url":"The :attribute field must be a valid URL.","validation.after":"The :attribute field must be a date after :date.","validation.after_or_equal":"The :attribute field must be a date after or equal to :date.","validation.alpha":"The :attribute field must only contain letters.","validation.alpha_dash":"The :attribute field must only contain letters, numbers, dashes, and underscores.","validation.alpha_num":"The :attribute field must only contain letters and numbers.","validation.array":"The :attribute field must be an array.","validation.ascii":"The :attribute field must only contain single-byte alphanumeric characters and symbols.","validation.before":"The :attribute field must be a date before :date.","validation.before_or_equal":"The :attribute field must be a date before or equal to :date.","validation.between.array":"The :attribute field must have between :min and :max items.","validation.between.file":"The :attribute field must be between :min and :max kilobytes.","validation.between.numeric":"The :attribute field must be between :min and :max.","validation.between.string":"The :attribute field must be between :min and :max characters.","validation.boolean":"The :attribute field must be true or false.","validation.can":"The :attribute field contains an unauthorized value.","validation.confirmed":"The :attribute field confirmation does not match.","validation.current_password":"The password is incorrect.","validation.date":"The :attribute field must be a valid date.","validation.date_equals":"The :attribute field must be a date equal to :date.","validation.date_format":"The :attribute field must match the format :format.","validation.decimal":"The :attribute field must have :decimal decimal places.","validation.declined":"The :attribute field must be declined.","validation.declined_if":"The :attribute field must be declined when :other is :value.","validation.different":"The :attribute field and :other must be different.","validation.digits":"The :attribute field must be :digits digits.","validation.digits_between":"The :attribute field must be between :min and :max digits.","validation.dimensions":"The :attribute field has invalid image dimensions.","validation.distinct":"The :attribute field has a duplicate value.","validation.doesnt_end_with":"The :attribute field must not end with one of the following: :values.","validation.doesnt_start_with":"The :attribute field must not start with one of the following: :values.","validation.email":"The :attribute field must be a valid email address.","validation.ends_with":"The :attribute field must end with one of the following: :values.","validation.enum":"The selected :attribute is invalid.","validation.exists":"The selected :attribute is invalid.","validation.extensions":"The :attribute field must have one of the following extensions: :values.","validation.file":"The :attribute field must be a file.","validation.filled":"The :attribute field must have a value.","validation.gt.array":"The :attribute field must have more than :value items.","validation.gt.file":"The :attribute field must be greater than :value kilobytes.","validation.gt.numeric":"The :attribute field must be greater than :value.","validation.gt.string":"The :attribute field must be greater than :value characters.","validation.gte.array":"The :attribute field must have :value items or more.","validation.gte.file":"The :attribute field must be greater than or equal to :value kilobytes.","validation.gte.numeric":"The :attribute field must be greater than or equal to :value.","validation.gte.string":"The :attribute field must be greater than or equal to :value characters.","validation.hex_color":"The :attribute field must be a valid hexadecimal color.","validation.image":"The :attribute field must be an image.","validation.in":"The selected :attribute is invalid.","validation.in_array":"The :attribute field must exist in :other.","validation.integer":"The :attribute field must be an integer.","validation.ip":"The :attribute field must be a valid IP address.","validation.ipv4":"The :attribute field must be a valid IPv4 address.","validation.ipv6":"The :attribute field must be a valid IPv6 address.","validation.json":"The :attribute field must be a valid JSON string.","validation.list":"The :attribute field must be a list.","validation.lowercase":"The :attribute field must be lowercase.","validation.lt.array":"The :attribute field must have less than :value items.","validation.lt.file":"The :attribute field must be less than :value kilobytes.","validation.lt.numeric":"The :attribute field must be less than :value.","validation.lt.string":"The :attribute field must be less than :value characters.","validation.lte.array":"The :attribute field must not have more than :value items.","validation.lte.file":"The :attribute field must be less than or equal to :value kilobytes.","validation.lte.numeric":"The :attribute field must be less than or equal to :value.","validation.lte.string":"The :attribute field must be less than or equal to :value characters.","validation.mac_address":"The :attribute field must be a valid MAC address.","validation.max.array":"The :attribute field must not have more than :max items.","validation.max.file":"The :attribute field must not be greater than :max kilobytes.","validation.max.numeric":"The :attribute field must not be greater than :max.","validation.max.string":"The :attribute field must not be greater than :max characters.","validation.max_digits":"The :attribute field must not have more than :max digits.","validation.mimes":"The :attribute field must be a file of type: :values.","validation.mimetypes":"The :attribute field must be a file of type: :values.","validation.min.array":"The :attribute field must have at least :min items.","validation.min.file":"The :attribute field must be at least :min kilobytes.","validation.min.numeric":"The :attribute field must be at least :min.","validation.min.string":"The :attribute field must be at least :min characters.","validation.min_digits":"The :attribute field must have at least :min digits.","validation.missing":"The :attribute field must be missing.","validation.missing_if":"The :attribute field must be missing when :other is :value.","validation.missing_unless":"The :attribute field must be missing unless :other is :value.","validation.missing_with":"The :attribute field must be missing when :values is present.","validation.missing_with_all":"The :attribute field must be missing when :values are present.","validation.multiple_of":"The :attribute field must be a multiple of :value.","validation.not_in":"The selected :attribute is invalid.","validation.not_regex":"The :attribute field format is invalid.","validation.numeric":"The :attribute field must be a number.","validation.password.letters":"The :attribute field must contain at least one letter.","validation.password.mixed":"The :attribute field must contain at least one uppercase and one lowercase letter.","validation.password.numbers":"The :attribute field must contain at least one number.","validation.password.symbols":"The :attribute field must contain at least one symbol.","validation.password.uncompromised":"The given :attribute has appeared in a data leak. Please choose a different :attribute.","validation.present":"The :attribute field must be present.","validation.present_if":"The :attribute field must be present when :other is :value.","validation.present_unless":"The :attribute field must be present unless :other is :value.","validation.present_with":"The :attribute field must be present when :values is present.","validation.present_with_all":"The :attribute field must be present when :values are present.","validation.prohibited":"The :attribute field is prohibited.","validation.prohibited_if":"The :attribute field is prohibited when :other is :value.","validation.prohibited_unless":"The :attribute field is prohibited unless :other is in :values.","validation.prohibits":"The :attribute field prohibits :other from being present.","validation.regex":"The :attribute field format is invalid.","validation.required":"The :attribute field is required.","validation.required_array_keys":"The :attribute field must contain entries for: :values.","validation.required_if":"The :attribute field is required when :other is :value.","validation.required_if_accepted":"The :attribute field is required when :other is accepted.","validation.required_unless":"The :attribute field is required unless :other is in :values.","validation.required_with":"The :attribute field is required when :values is present.","validation.required_with_all":"The :attribute field is required when :values are present.","validation.required_without":"The :attribute field is required when :values is not present.","validation.required_without_all":"The :attribute field is required when none of :values are present.","validation.same":"The :attribute field must match :other.","validation.size.array":"The :attribute field must contain :size items.","validation.size.file":"The :attribute field must be :size kilobytes.","validation.size.numeric":"The :attribute field must be :size.","validation.size.string":"The :attribute field must be :size characters.","validation.starts_with":"The :attribute field must start with one of the following: :values.","validation.string":"The :attribute field must be a string.","validation.timezone":"The :attribute field must be a valid timezone.","validation.unique":"The :attribute has already been taken.","validation.uploaded":"The :attribute failed to upload.","validation.uppercase":"The :attribute field must be uppercase.","validation.url":"The :attribute field must be a valid URL.","validation.ulid":"The :attribute field must be a valid ULID.","validation.uuid":"The :attribute field must be a valid UUID.","validation.custom.attribute-name.rule-name":"custom-message","validation.attributes":[]}

0 commit comments

Comments
 (0)