Skip to content

Commit 5720888

Browse files
committed
Refactoring logging a bit.
1 parent c8154d0 commit 5720888

13 files changed

+409
-378
lines changed

eFormCore/Communication/Communicator.cs

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

eFormCore/Core.cs

Lines changed: 258 additions & 262 deletions
Large diffs are not rendered by default.

eFormCore/Handlers/AnswerCompletedHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async Task Handle(AnswerCompleted message)
4949
{
5050
try
5151
{
52-
log.LogEverything("AnswerCompletedHandler.Handle", $"Parsing answer for id {message.MicrotringUUID}");
52+
log.LogDebug("AnswerCompletedHandler.Handle", $"Parsing answer for id {message.MicrotringUUID}");
5353
await core.GetAllSurveyConfigurations().ConfigureAwait(false);
5454
await core.GetAnswersForQuestionSet(message.MicrotringUUID).ConfigureAwait(false);
5555
await sqlController.NotificationUpdate(message.NotificationUId,
@@ -60,7 +60,7 @@ await sqlController.NotificationUpdate(message.NotificationUId,
6060
}
6161
catch (Exception ex)
6262
{
63-
log.LogException("AnswerCompletedHandler.Handle",
63+
log.LogFail("AnswerCompletedHandler.Handle",
6464
$"Could not parse answer for id {message.MicrotringUUID}, got exception {ex.Message}", ex);
6565
await sqlController.NotificationUpdate(message.NotificationUId,
6666
message.MicrotringUUID,

eFormCore/Handlers/EformCompletedHandler.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private async Task<bool> CheckStatusByMicrotingUid(int microtingUid)
8181
List<CaseDto> lstCase = new List<CaseDto>();
8282

8383
CaseDto concreteCase = await _sqlController.CaseReadByMUId(microtingUid);
84-
_log.LogEverything("EformCompletedHandler.CheckStatusByMicrotingUid", concreteCase + " has been matched");
84+
_log.LogDebug("EformCompletedHandler.CheckStatusByMicrotingUid", concreteCase + " has been matched");
8585

8686
if (concreteCase.CaseUId == "" || concreteCase.CaseUId == "ReversedCase")
8787
lstCase.Add(concreteCase);
@@ -109,7 +109,7 @@ await _sqlController
109109

110110
if (resp.Type == Response.ResponseTypes.Success)
111111
{
112-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
112+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
113113
"resp.Type == Response.ResponseTypes.Success (true)");
114114
if (resp.Checks.Count > 0)
115115
{
@@ -120,7 +120,7 @@ await SaveResult(resp, respXml, dbContext, microtingUid, null, aCase)
120120
}
121121
else
122122
{
123-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
123+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
124124
"resp.Type == Response.ResponseTypes.Success (false)");
125125
throw new Exception("Failed to retrive eForm " + microtingUid + " from site " +
126126
aCase.SiteUId);
@@ -167,7 +167,7 @@ private bool FetchData(string microtingUid, CaseDto concreteCase, string checkId
167167
resp = resp.XmlToClassUsingXmlDocument(respXml);
168168
if (resp.Type == Response.ResponseTypes.Success)
169169
{
170-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
170+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
171171
"resp.Type == Response.ResponseTypes.Success (true)");
172172
if (resp.Checks.Count > 0)
173173
{
@@ -219,20 +219,20 @@ private async Task<int> SaveResult(Response resp, string respXml, MicrotingDbCon
219219
}
220220
else
221221
{
222-
_log.LogEverything(_t.GetMethodName("Core"),
222+
_log.LogDebug(_t.GetMethodName("Core"),
223223
"downloadUploadedData failed for uploadedDataid :" + uploadedDataid);
224224
}
225225
}
226226

227227
CultureInfo culture = CultureInfo.CreateSpecificCulture("da-DK");
228228
DateTime dateTime = DateTime.ParseExact(check.Date, "yyyy-MM-dd HH:mm:ss", culture);
229-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"), $"XML date is {check.Date}");
230-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
229+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"), $"XML date is {check.Date}");
230+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
231231
$"Parsed date is {dateTime.ToString(CultureInfo.InvariantCulture)}");
232232

233233
await _sqlController.CaseUpdateCompleted(microtingUid, (int)check.Id, dateTime, (int)workerUId,
234234
(int)unitUId);
235-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
235+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
236236
"sqlController.CaseUpdateCompleted(...)");
237237

238238
// IF needed retract case, thereby completing the process
@@ -244,7 +244,7 @@ await _sqlController.CaseUpdateCompleted(microtingUid, (int)check.Id, dateTime,
244244

245245
if (respXml.Contains("<Value type=\"success\">"))
246246
{
247-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"),
247+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"),
248248
aCase + " has been retracted");
249249
}
250250
else
@@ -254,12 +254,12 @@ await _sqlController.CaseUpdateCompleted(microtingUid, (int)check.Id, dateTime,
254254
}
255255

256256
await _sqlController.CaseRetract(microtingUid, (int)check.Id);
257-
_log.LogEverything(_t.GetMethodName("EformCompletedHandler"), "sqlController.CaseRetract(...)");
257+
_log.LogDebug(_t.GetMethodName("EformCompletedHandler"), "sqlController.CaseRetract(...)");
258258
// TODO add case.id
259259
CaseDto cDto = await _sqlController.CaseReadByMUId(microtingUid);
260260
Console.WriteLine($"info: {DateTime.Now} FireHandleCaseCompleted");
261261
await _core.FireHandleCaseCompleted(cDto);
262-
_log.LogStandard(_t.GetMethodName("EformCompletedHandler"), cDto + " has been completed");
262+
_log.LogInfo(_t.GetMethodName("EformCompletedHandler"), cDto + " has been completed");
263263
i++;
264264
returnId = (int)check.Id;
265265
}

eFormCore/Handlers/EformDeleteFromServerHandler.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public async Task Handle(EformDeleteFromServer message)
6262
{
6363
try
6464
{
65-
_log.LogException(_t.GetMethodName("EformDeleteFromServerHandler"),
65+
_log.LogFail(_t.GetMethodName("EformDeleteFromServerHandler"),
6666
methodName + " (EformDeleteFromServer message) failed, with message.MicrotringUUID " +
6767
message.MicrotringUUID, ex);
6868
}
6969
catch (Exception)
7070
{
71-
_log.LogException(_t.GetMethodName("EformDeleteFromServerHandler"),
71+
_log.LogFail(_t.GetMethodName("EformDeleteFromServerHandler"),
7272
methodName + " (EformDeleteFromServer message) failed", ex);
7373
}
7474
}
@@ -79,7 +79,7 @@ private async Task DeleteCase(EformDeleteFromServer message)
7979
int microtingUId = message.MicrotringUUID;
8080
string methodName = "EformDeleteFromServerHandler";
8181

82-
_log.LogStandard(_t.GetMethodName("EformDeleteFromServerHandler"), methodName + " called");
82+
_log.LogInfo(_t.GetMethodName("EformDeleteFromServerHandler"), methodName + " called");
8383
_log.LogVariable(_t.GetMethodName("EformDeleteFromServerHandler"), nameof(microtingUId), microtingUId);
8484

8585
var cDto = await _sqlController.CaseReadByMUId(microtingUId);
@@ -88,9 +88,9 @@ private async Task DeleteCase(EformDeleteFromServer message)
8888

8989
if (xmlResponse.Contains("Error occured: Contact Microting"))
9090
{
91-
_log.LogEverything(_t.GetMethodName("EformDeleteFromServerHandler"), "XML response:");
92-
_log.LogEverything(_t.GetMethodName("EformDeleteFromServerHandler"), xmlResponse);
93-
_log.LogEverything("DELETE ERROR", methodName + " failed for microtingUId: " + microtingUId);
91+
_log.LogDebug(_t.GetMethodName("EformDeleteFromServerHandler"), "XML response:");
92+
_log.LogDebug(_t.GetMethodName("EformDeleteFromServerHandler"), xmlResponse);
93+
_log.LogDebug("DELETE ERROR", methodName + " failed for microtingUId: " + microtingUId);
9494
return;
9595
}
9696

@@ -99,20 +99,20 @@ private async Task DeleteCase(EformDeleteFromServer message)
9999
try
100100
{
101101
resp = resp.XmlToClass(xmlResponse);
102-
_log.LogException(_t.GetMethodName("EformDeleteFromServerHandler"), methodName + " failed",
102+
_log.LogFail(_t.GetMethodName("EformDeleteFromServerHandler"), methodName + " failed",
103103
new Exception("Error from Microting server: " + resp.Value));
104104
return;
105105
}
106106
catch (Exception ex)
107107
{
108108
try
109109
{
110-
_log.LogException(_t.GetMethodName("EformDeleteFromServerHandler"),
110+
_log.LogFail(_t.GetMethodName("EformDeleteFromServerHandler"),
111111
methodName + " (string " + microtingUId + ") failed", ex);
112112
}
113113
catch
114114
{
115-
_log.LogException(_t.GetMethodName("EformDeleteFromServerHandler"),
115+
_log.LogFail(_t.GetMethodName("EformDeleteFromServerHandler"),
116116
methodName + " (string microtingUId) failed", ex);
117117
}
118118

@@ -129,8 +129,8 @@ private async Task DeleteCase(EformDeleteFromServer message)
129129
break;
130130
}
131131

132-
_log.LogEverything(_t.GetMethodName("EformDeleteFromServerHandler"), "XML response:");
133-
_log.LogEverything(_t.GetMethodName("EformDeleteFromServerHandler"), xmlResponse);
132+
_log.LogDebug(_t.GetMethodName("EformDeleteFromServerHandler"), "XML response:");
133+
_log.LogDebug(_t.GetMethodName("EformDeleteFromServerHandler"), xmlResponse);
134134

135135
resp = resp.XmlToClass(xmlResponse);
136136
if (resp.Type.ToString() == "Success")
@@ -142,7 +142,7 @@ private async Task DeleteCase(EformDeleteFromServer message)
142142
cDto = await _sqlController.CaseReadByMUId(microtingUId);
143143
await _core.FireHandleCaseDeleted(cDto);
144144

145-
_log.LogStandard(_t.GetMethodName("EformDeleteFromServerHandler"), cDto + " has been removed");
145+
_log.LogInfo(_t.GetMethodName("EformDeleteFromServerHandler"), cDto + " has been removed");
146146

147147
return;
148148
}
@@ -159,7 +159,7 @@ private async Task DeleteCase(EformDeleteFromServer message)
159159

160160
cDto = await _sqlController.CaseReadByMUId(microtingUId);
161161
await _core.FireHandleCaseDeleted(cDto);
162-
_log.LogStandard(_t.GetMethodName("EformDeleteFromServerHandler"), cDto + " has been removed");
162+
_log.LogInfo(_t.GetMethodName("EformDeleteFromServerHandler"), cDto + " has been removed");
163163
}
164164
catch (Exception ex)
165165
{

eFormCore/Handlers/EformParsedByServerHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public EformParsedByServerHandler(SqlController sqlController, Core core, Log lo
4949
public async Task Handle(EformParsedByServer message)
5050
{
5151
await using MicrotingDbContext dbContext = _core.DbContextHelper.GetDbContext();
52-
_log.LogStandard("EformParsedByServer.Handle called", $"NotificationId: {message.NotificationId}, MicrotringUUID: {message.MicrotringUUID}");
52+
_log.LogInfo("EformParsedByServer.Handle called", $"NotificationId: {message.NotificationId}, MicrotringUUID: {message.MicrotringUUID}");
5353
await _sqlController.NotificationCreate(message.NotificationId, message.MicrotringUUID,
5454
Constants.Notifications.EformParsedByServer);
5555

eFormCore/Handlers/SurveyConfigurationChangedHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task Handle(SurveyConfigurationChanged message)
2525
{
2626
try
2727
{
28-
log.LogEverything("SurveyConfigurationChangedHandler.Handle",
28+
log.LogDebug("SurveyConfigurationChangedHandler.Handle",
2929
"Calling GetAllQuestionSets to load all question sets");
3030
await core.GetAllQuestionSets().ConfigureAwait(false);
3131
await sqlController.NotificationUpdate(message.NotificationUId,
@@ -36,7 +36,7 @@ await sqlController.NotificationUpdate(message.NotificationUId,
3636
}
3737
catch (Exception ex)
3838
{
39-
log.LogException("SurveyConfigurationChangedHandler.Handle", $"Got exception {ex.Message}", ex);
39+
log.LogFail("SurveyConfigurationChangedHandler.Handle", $"Got exception {ex.Message}", ex);
4040
await sqlController.NotificationUpdate(message.NotificationUId,
4141
message.MicrotringUUID,
4242
Constants.WorkflowStates.NotFound,

eFormCore/Handlers/TranscribeAudioFileHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public async Task Handle(TranscribeAudioFile message)
5656
}
5757
catch (Exception ex)
5858
{
59-
log.LogException(t.GetMethodName("TranscribeAudioFileHandler"),
59+
log.LogFail(t.GetMethodName("TranscribeAudioFileHandler"),
6060
"Failed to transcribe audio file with uploadedDataId: " + message.uploadedDataId, ex);
6161
}
6262
}

eFormCore/Handlers/TranscriptionCompletedHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ public async Task Handle(TranscriptionCompleted message)
6969

7070
if (ud.FileName.Contains("3gp"))
7171
{
72-
log.LogStandard("TranscriptionCompletedHandler.Handle", "file_name contains 3gp");
72+
log.LogInfo("TranscriptionCompletedHandler.Handle", "file_name contains 3gp");
7373
string urlStr = sqlController.SettingRead(Settings.comSpeechToText).GetAwaiter().GetResult() +
7474
"/download_file/" + message.MicrotringUUID + ".wav?token=" +
7575
sqlController.SettingRead(Settings.token).GetAwaiter().GetResult();
7676
using var client = new HttpClient();
7777
try
7878
{
79-
log.LogStandard("TranscriptionCompletedHandler.Handle",
79+
log.LogInfo("TranscriptionCompletedHandler.Handle",
8080
"Trying to download file from : " + urlStr);
8181
var stream = await client.GetStreamAsync(urlStr);
8282
MemoryStream baseMemoryStream = new MemoryStream();
@@ -96,7 +96,7 @@ public async Task Handle(TranscriptionCompleted message)
9696
await sqlController.NotificationUpdate(message.notificationUId, message.MicrotringUUID,
9797
Constants.WorkflowStates.Processed, "", "");
9898

99-
log.LogStandard("TranscriptionCompletedHandler.Handle",
99+
log.LogInfo("TranscriptionCompletedHandler.Handle",
100100
"Transcription with id " + message.MicrotringUUID + " has been transcribed");
101101
}
102102
catch (Exception ex)

eFormCore/Handlers/UnitActivatedHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public async Task Handle(UnitActivated message)
5555
await _sqlController.NotificationUpdate(message.notificationUId, message.MicrotringUUID,
5656
Constants.WorkflowStates.Processed, "", "");
5757

58-
_log.LogStandard("UnitActivatedHandler.Handle",
58+
_log.LogInfo("UnitActivatedHandler.Handle",
5959
"Unit with id " + message.MicrotringUUID + " has been activated");
6060

6161
NoteDto noteDto = new NoteDto(message.notificationUId, message.MicrotringUUID,

0 commit comments

Comments
 (0)