Skip to content

Commit

Permalink
Merge pull request #675 from bcgov/2.0.7
Browse files Browse the repository at this point in the history
Add date to timestamp for logging
  • Loading branch information
bcgov-brwang authored May 18, 2023
2 parents 376ef3c + 9277788 commit a437399
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const phases = {
host: `hmcr-d3d940-dev.apps.silver.devops.gov.bc.ca`,
url_prefix: "dev-",
bceid_service: ".test",
oas_server: "devoas4",
export_server: "devoas4",
oas_server: "prdoas5",
export_server: "tstoas5",
dotnet_env: "Development",
transient: true,
hangfire_cpu: "300m",
Expand Down
4 changes: 0 additions & 4 deletions .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { OpenShiftClientX } = require("@bcgov/pipeline-cli");
const path = require("path");

const util = require("./util");
const KeyCloakClient = require("./keycloak");

module.exports = (settings) => {
const phases = settings.phases;
Expand All @@ -17,15 +16,12 @@ module.exports = (settings) => {
path.resolve(__dirname, "../../openshift")
);
var objects = [];
const kc = new KeyCloakClient(settings, oc);
const logDbSecret = util.getSecret(
oc,
phases[phase].namespace,
`${phases[phase].name}-logdb${phases[phase].suffix}`
);

kc.addUris();

// The deployment of your cool app goes here ▼▼▼
objects.push(
...oc.processDeploymentTemplate(
Expand Down
12 changes: 10 additions & 2 deletions api/Hmcr.Api/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"Args": {
"configure": [
{
"Name": "Console"
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
}
Expand Down Expand Up @@ -49,7 +52,12 @@
"renderAsText": false
}
},
"timestamp": "TimestampColumnWriter",
"timestamp": {
"Name": "TimestampColumnWriter",
"Args": {
"dbType": "Timestamp"
}
},
"exception": "ExceptionColumnWriter",
"log_event": "LogEventSerializedColumnWriter",
"props_test": {
Expand Down
8 changes: 6 additions & 2 deletions api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Hmcr.Model.Utils;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -26,11 +27,13 @@ public partial class AppDbContext
private const string AppLastUpdateUserGuid = "AppLastUpdateUserGuid";
private const string AppLastUpdateTimestamp = "AppLastUpdateTimestamp";

private readonly ILogger<AppDbContext> _logger;
public readonly HmcrCurrentUser _currentUser;

public AppDbContext(DbContextOptions<AppDbContext> options, HmcrCurrentUser currentUser)
public AppDbContext(DbContextOptions<AppDbContext> options, ILogger<AppDbContext> logger, HmcrCurrentUser currentUser)
: base(options)
{
_logger = logger;
_currentUser = currentUser;
}

Expand All @@ -46,7 +49,8 @@ public override int SaveChanges()
}
catch (Exception e)
{
Console.WriteLine(e);
string exceptionMessage = e.ToString();
_logger.LogError($"AppDbContext Exception: {exceptionMessage}");
throw;
}

Expand Down
3 changes: 2 additions & 1 deletion api/Hmcr.Domain/Hangfire/WorkReportJobService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ private List<WorkReportGeometry> PerformAnalyticalValidationBatchAsync(List<Work
/*** Time profiling ***
* DateTime EndAt = DateTime.Now;
TimeSpan TimeDifference = EndAt - StartAt;
Console.WriteLine("Total Duration in milliseconds: {0}", TimeDifference.TotalMilliseconds.ToString());*/
string durationMsStr = TimeDifference.TotalMilliseconds.ToString();
_logger.LogInformation($"Total Duration in milliseconds: {durationMsStr}");*/

return workReports.ToList();
}
Expand Down
2 changes: 1 addition & 1 deletion api/Hmcr.Domain/Services/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private void SendEmail(List<MailboxAddress> recipients, string subject, string h
// return true;
//}

//Console.WriteLine("Unable to validate certificate chain.");
//_logger.LogError("Unable to validate certificate chain.");
//return false;

return true;
Expand Down
6 changes: 6 additions & 0 deletions api/Hmcr.Domain/Services/RockfallReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
}
}

if (row == null)
{
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
break;
}

row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
rows.Add(row);
}
Expand Down
6 changes: 6 additions & 0 deletions api/Hmcr.Domain/Services/WildlifeReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
}
}

if (row == null)
{
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
break;
}

row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
rows.Add(row);
}
Expand Down
6 changes: 6 additions & 0 deletions api/Hmcr.Domain/Services/WorkReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ protected override async Task<bool> ParseRowsAsync(SubmissionObjectCreateDto sub
}
}

if (row == null)
{
errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows");
break;
}

row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea);
rows.Add(row);
}
Expand Down
7 changes: 6 additions & 1 deletion api/Hmcr.Hangfire/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
"Name": "Async",
"Args": {
"configure": [
{ "Name": "Console" }
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
}
}
Expand Down
20 changes: 16 additions & 4 deletions openshift/configmaps/api-appsettings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ objects:
{
"Name": "Async",
"Args": {
"configure": [ { "Name": "Console" } ]
"configure": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
}
}
]
}
},
{
Expand All @@ -48,7 +55,12 @@ objects:
"renderAsText": false
}
},
"timestamp": "TimestampColumnWriter",
"timestamp": {
"Name": "TimestampColumnWriter",
"Args": {
"dbType": "Timestamp"
}
},
"exception": "ExceptionColumnWriter",
"log_event": "LogEventSerializedColumnWriter",
"props_test": {
Expand Down Expand Up @@ -141,12 +153,12 @@ parameters:
displayName: EXPORT_URL
name: EXPORT_URL
required: true
value: "https://devoas1.apps.th.gov.bc.ca"
value: "https://tstoas5.apps.th.gov.bc.ca"
- description: GeoServer CHRIS API URL
displayName: OAS_URL
name: OAS_URL
required: true
value: "https://devoas1.apps.th.gov.bc.ca"
value: "https://prdoas5.apps.th.gov.bc.ca"
- description: Default timeout value for CHRIS/GeoServer API calls
displayName: GEOSERVER_TIMEOUT
name: GEOSERVER_TIMEOUT
Expand Down

0 comments on commit a437399

Please sign in to comment.