Skip to content

Commit a437399

Browse files
authored
Merge pull request #675 from bcgov/2.0.7
Add date to timestamp for logging
2 parents 376ef3c + 9277788 commit a437399

File tree

11 files changed

+61
-17
lines changed

11 files changed

+61
-17
lines changed

.pipeline/lib/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const phases = {
2929
host: `hmcr-d3d940-dev.apps.silver.devops.gov.bc.ca`,
3030
url_prefix: "dev-",
3131
bceid_service: ".test",
32-
oas_server: "devoas4",
33-
export_server: "devoas4",
32+
oas_server: "prdoas5",
33+
export_server: "tstoas5",
3434
dotnet_env: "Development",
3535
transient: true,
3636
hangfire_cpu: "300m",

.pipeline/lib/deploy.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const { OpenShiftClientX } = require("@bcgov/pipeline-cli");
33
const path = require("path");
44

55
const util = require("./util");
6-
const KeyCloakClient = require("./keycloak");
76

87
module.exports = (settings) => {
98
const phases = settings.phases;
@@ -17,15 +16,12 @@ module.exports = (settings) => {
1716
path.resolve(__dirname, "../../openshift")
1817
);
1918
var objects = [];
20-
const kc = new KeyCloakClient(settings, oc);
2119
const logDbSecret = util.getSecret(
2220
oc,
2321
phases[phase].namespace,
2422
`${phases[phase].name}-logdb${phases[phase].suffix}`
2523
);
2624

27-
kc.addUris();
28-
2925
// The deployment of your cool app goes here ▼▼▼
3026
objects.push(
3127
...oc.processDeploymentTemplate(

api/Hmcr.Api/appsettings.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"Args": {
2222
"configure": [
2323
{
24-
"Name": "Console"
24+
"Name": "Console",
25+
"Args": {
26+
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
27+
}
2528
}
2629
]
2730
}
@@ -49,7 +52,12 @@
4952
"renderAsText": false
5053
}
5154
},
52-
"timestamp": "TimestampColumnWriter",
55+
"timestamp": {
56+
"Name": "TimestampColumnWriter",
57+
"Args": {
58+
"dbType": "Timestamp"
59+
}
60+
},
5361
"exception": "ExceptionColumnWriter",
5462
"log_event": "LogEventSerializedColumnWriter",
5563
"props_test": {

api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Hmcr.Model.Utils;
55
using Microsoft.EntityFrameworkCore;
66
using Microsoft.EntityFrameworkCore.ChangeTracking;
7+
using Microsoft.Extensions.Logging;
78
using System;
89
using System.Collections.Generic;
910
using System.Linq;
@@ -26,11 +27,13 @@ public partial class AppDbContext
2627
private const string AppLastUpdateUserGuid = "AppLastUpdateUserGuid";
2728
private const string AppLastUpdateTimestamp = "AppLastUpdateTimestamp";
2829

30+
private readonly ILogger<AppDbContext> _logger;
2931
public readonly HmcrCurrentUser _currentUser;
3032

31-
public AppDbContext(DbContextOptions<AppDbContext> options, HmcrCurrentUser currentUser)
33+
public AppDbContext(DbContextOptions<AppDbContext> options, ILogger<AppDbContext> logger, HmcrCurrentUser currentUser)
3234
: base(options)
3335
{
36+
_logger = logger;
3437
_currentUser = currentUser;
3538
}
3639

@@ -46,7 +49,8 @@ public override int SaveChanges()
4649
}
4750
catch (Exception e)
4851
{
49-
Console.WriteLine(e);
52+
string exceptionMessage = e.ToString();
53+
_logger.LogError($"AppDbContext Exception: {exceptionMessage}");
5054
throw;
5155
}
5256

api/Hmcr.Domain/Hangfire/WorkReportJobService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ private List<WorkReportGeometry> PerformAnalyticalValidationBatchAsync(List<Work
257257
/*** Time profiling ***
258258
* DateTime EndAt = DateTime.Now;
259259
TimeSpan TimeDifference = EndAt - StartAt;
260-
Console.WriteLine("Total Duration in milliseconds: {0}", TimeDifference.TotalMilliseconds.ToString());*/
260+
string durationMsStr = TimeDifference.TotalMilliseconds.ToString();
261+
_logger.LogInformation($"Total Duration in milliseconds: {durationMsStr}");*/
261262

262263
return workReports.ToList();
263264
}

api/Hmcr.Domain/Services/EmailService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void SendEmail(List<MailboxAddress> recipients, string subject, string h
188188
// return true;
189189
//}
190190

191-
//Console.WriteLine("Unable to validate certificate chain.");
191+
//_logger.LogError("Unable to validate certificate chain.");
192192
//return false;
193193

194194
return true;

api/Hmcr.Domain/Services/RockfallReportService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
7676
}
7777
}
7878

79+
if (row == null)
80+
{
81+
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
82+
break;
83+
}
84+
7985
row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
8086
rows.Add(row);
8187
}

api/Hmcr.Domain/Services/WildlifeReportService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
7474
}
7575
}
7676

77+
if (row == null)
78+
{
79+
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
80+
break;
81+
}
82+
7783
row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
7884
rows.Add(row);
7985
}

api/Hmcr.Domain/Services/WorkReportService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
7676
}
7777
}
7878

79+
if (row == null)
80+
{
81+
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
82+
break;
83+
}
84+
7985
row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
8086
rows.Add(row);
8187
}

api/Hmcr.Hangfire/appsettings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
"Name": "Async",
1818
"Args": {
1919
"configure": [
20-
{ "Name": "Console" }
20+
{
21+
"Name": "Console",
22+
"Args": {
23+
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
24+
}
25+
}
2126
]
2227
}
2328
}

0 commit comments

Comments
 (0)