Skip to content

Commit 45ab8a8

Browse files
committed
Adding logs on map service
1 parent 6991ec7 commit 45ab8a8

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/AzureMapsControl.Components/Logger/Extensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ internal enum AzureMapLogEvent
4040
AzureMap_Popup_RemoveAsync = 1033,
4141
AzureMap_Popup_UpdateAsync = 1034,
4242
AzureMap_ClearPopupsAsync = 1035,
43-
AzureMap_PopupEventReceivedAsync = 1036
43+
AzureMap_PopupEventReceivedAsync = 1036,
44+
MapService_AddMapAsync = 2000
4445
}
4546

4647
internal static class Extensions

src/AzureMapsControl.Components/Map/MapService.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@
22
{
33
using System.Threading.Tasks;
44

5+
using AzureMapsControl.Components.Logger;
6+
using Microsoft.Extensions.Logging;
7+
58
public delegate Task MapReadyEvent();
69

710
internal class MapService : IMapAdderService
811
{
12+
private readonly ILogger<MapService> _logger;
13+
914
public Map Map
1015
{
1116
get;
1217
private set;
1318
}
1419

20+
public MapService(ILogger<MapService> logger) => _logger = logger;
21+
1522
public event MapReadyEvent OnMapReadyAsync;
1623

1724
public async Task AddMapAsync(Map map)
1825
{
26+
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.MapService_AddMapAsync, "Adding instance of map");
1927
Map = map;
2028

2129
if (OnMapReadyAsync != null)
2230
{
31+
_logger?.LogAzureMapsControlInfo(AzureMapLogEvent.MapService_AddMapAsync, "Emitting OnMapReadyAsync");
2332
await OnMapReadyAsync.Invoke();
2433
}
2534
}

tests/AzureMapsControl.Components.Tests/Map/MapService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class MapServiceTests
1010
public async void Should_AddMap_Async()
1111
{
1212
var map = new Map("id");
13-
var service = new MapService();
13+
var service = new MapService(null);
1414
await service.AddMapAsync(map);
1515
Assert.Equal(map, service.Map);
1616
}
@@ -19,7 +19,7 @@ public async void Should_AddMap_Async()
1919
public async void Should_AddMapAndTriggerOnReady_Async()
2020
{
2121
var map = new Map("id");
22-
var service = new MapService();
22+
var service = new MapService(null);
2323

2424
var eventReceived = false;
2525

0 commit comments

Comments
 (0)