Skip to content

Commit

Permalink
#2379 Added some logging to MDT string importing
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed May 16, 2024
1 parent fba75f7 commit cdad636
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 132 deletions.
5 changes: 5 additions & 0 deletions app/Logic/Structs/IngameXY.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public function toArray(): array
];
}

public function toArrayWithFloor(): array
{
return ['x' => $this->x, 'y' => $this->y, 'floor_id' => optional($this->floor)->id];
}

public function __clone()
{
return new IngameXY(
Expand Down
3 changes: 3 additions & 0 deletions app/Providers/LoggingServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
use App\Service\CombatLog\Logging\ResultEventDungeonRouteBuilderLoggingInterface;
use App\Service\CombatLogEvent\Logging\CombatLogEventServiceLogging;
use App\Service\CombatLogEvent\Logging\CombatLogEventServiceLoggingInterface;
use App\Service\MDT\Logging\MDTImportStringServiceLogging;
use App\Service\MDT\Logging\MDTImportStringServiceLoggingInterface;
use App\Service\MDT\Logging\MDTMappingExportServiceLogging;
use App\Service\MDT\Logging\MDTMappingExportServiceLoggingInterface;
use App\Service\MDT\Logging\MDTMappingImportServiceLogging;
Expand Down Expand Up @@ -93,6 +95,7 @@ public function register(): void
$this->app->bind(CombatLogEventServiceLoggingInterface::class, CombatLogEventServiceLogging::class);

// MDT
$this->app->bind(MDTImportStringServiceLoggingInterface::class, MDTImportStringServiceLogging::class);
$this->app->bind(MDTMappingExportServiceLoggingInterface::class, MDTMappingExportServiceLogging::class);
$this->app->bind(MDTMappingImportServiceLoggingInterface::class, MDTMappingImportServiceLogging::class);

Expand Down
6 changes: 4 additions & 2 deletions app/Service/Coordinates/CoordinatesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function calculateIngameLocationForMapLocation(LatLng $latLng): IngameXY
if ($floor === null) {
throw new InvalidArgumentException('No floor set for latlng!');
} else if ($floor->facade) {
throw new InvalidArgumentException('Unable to convert latlng that is on facade floor!');
throw new InvalidArgumentException(
sprintf('Unable to convert latlng %s that is on facade floor!', json_encode($latLng->toArrayWithFloor()))
);
}

$ingameMapSizeX = $floor->ingame_max_x - $floor->ingame_min_x;
Expand All @@ -57,7 +59,7 @@ public function calculateMapLocationForIngameLocation(IngameXY $ingameXY): LatLn
if ($targetFloor === null) {
throw new InvalidArgumentException('No floor set for ingame XY!');
} else if ($targetFloor->facade) {
throw new InvalidArgumentException('Unable to convert ingame XY that is on facade floor!');
sprintf('Unable to convert ingame XY %s that is on facade floor!', json_encode($ingameXY->toArrayWithFloor()));
}

$ingameMapSizeX = $targetFloor->ingame_max_x - $targetFloor->ingame_min_x;
Expand Down
34 changes: 34 additions & 0 deletions app/Service/MDT/Logging/MDTImportStringServiceLogging.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace App\Service\MDT\Logging;

use App\Logging\StructuredLogging;

class MDTImportStringServiceLogging extends StructuredLogging implements MDTImportStringServiceLoggingInterface
{

public function getDetailsStart(): void
{
$this->start(__METHOD__);
}

public function getDetailsEnd(): void
{
$this->end(__METHOD__);
}

public function getDungeonRouteStart(bool $sandbox, bool $save, bool $importAsThisWeek): void
{
$this->start(__METHOD__, get_defined_vars());
}

public function getDungeonRouteEnd(): void
{
$this->end(__METHOD__);
}

public function setEncodedStringEncodedString(string $encodedString): void
{
$this->debug(__METHOD__, get_defined_vars());
}
}
16 changes: 16 additions & 0 deletions app/Service/MDT/Logging/MDTImportStringServiceLoggingInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Service\MDT\Logging;

interface MDTImportStringServiceLoggingInterface
{
public function getDetailsStart(): void;

public function getDetailsEnd(): void;

public function getDungeonRouteStart(bool $sandbox, bool $save, bool $importAsThisWeek): void;

public function getDungeonRouteEnd(): void;

public function setEncodedStringEncodedString(string $encodedString): void;
}
2 changes: 1 addition & 1 deletion app/Service/MDT/MDTBaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Support\Facades\Artisan;
use Lua;

class MDTBaseService
abstract class MDTBaseService
{
/**
* Gets a Lua instance and load all the required files in it.
Expand Down
Loading

0 comments on commit cdad636

Please sign in to comment.