From e950801f56cb402d84a92e63f110fdc2c0d922d3 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Wed, 28 Dec 2022 18:00:24 -0500 Subject: [PATCH] better loggin --- src/BirdsiteLive.Domain/MigrationService.cs | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/BirdsiteLive.Domain/MigrationService.cs b/src/BirdsiteLive.Domain/MigrationService.cs index 3dc2eb9..e0dfdb5 100644 --- a/src/BirdsiteLive.Domain/MigrationService.cs +++ b/src/BirdsiteLive.Domain/MigrationService.cs @@ -14,6 +14,7 @@ using BirdsiteLive.DAL.Models; using BirdsiteLive.Domain.Enum; using System.Net.Http; using BirdsiteLive.Common.Regexes; +using Microsoft.Extensions.Logging; namespace BirdsiteLive.Domain { @@ -26,9 +27,10 @@ namespace BirdsiteLive.Domain private readonly ITwitterUserDal _twitterUserDal; private readonly IFollowersDal _followersDal; private readonly IHttpClientFactory _httpClientFactory; - + private readonly ILogger _logger; + #region Ctor - public MigrationService(ITwitterTweetsService twitterTweetsService, IActivityPubService activityPubService, ITwitterUserDal twitterUserDal, IFollowersDal followersDal, InstanceSettings instanceSettings, ITheFedInfoService theFedInfoService, IHttpClientFactory httpClientFactory) + public MigrationService(ITwitterTweetsService twitterTweetsService, IActivityPubService activityPubService, ITwitterUserDal twitterUserDal, IFollowersDal followersDal, InstanceSettings instanceSettings, ITheFedInfoService theFedInfoService, IHttpClientFactory httpClientFactory, ILogger logger) { _twitterTweetsService = twitterTweetsService; _activityPubService = activityPubService; @@ -37,6 +39,7 @@ namespace BirdsiteLive.Domain _instanceSettings = instanceSettings; _theFedInfoService = theFedInfoService; _httpClientFactory = httpClientFactory; + _logger = logger; } #endregion @@ -187,7 +190,7 @@ namespace BirdsiteLive.Domain } catch (Exception e) { - Console.WriteLine(e); + _logger.LogError(e, e.Message); } } }); @@ -232,7 +235,14 @@ namespace BirdsiteLive.Domain var t1 = Task.Run(async () => { - await _activityPubService.DeleteUserAsync(acct, host, sharedInbox); + try + { + await _activityPubService.DeleteUserAsync(acct, host, sharedInbox); + } + catch (Exception e) + { + _logger.LogError(e, e.Message); + } }); } @@ -246,7 +256,14 @@ namespace BirdsiteLive.Domain var t1 = Task.Run(async () => { - await _activityPubService.DeleteUserAsync(acct, host, sharedInbox); + try + { + await _activityPubService.DeleteUserAsync(acct, host, sharedInbox); + } + catch (Exception e) + { + _logger.LogError(e, e.Message); + } }); } }); @@ -287,13 +304,13 @@ namespace BirdsiteLive.Domain } catch (Exception e) { - Console.WriteLine(e); + _logger.LogError(e, e.Message); } } } catch (Exception e) { - Console.WriteLine(e); + _logger.LogError(e, e.Message); } }