Skip to content

Commit 5f6ab93

Browse files
authored
Merge pull request #507 from bcgov/1.0.5
Add date to timestamp for logging
2 parents 9b8f9c4 + ea24a51 commit 5f6ab93

File tree

8 files changed

+46
-21
lines changed

8 files changed

+46
-21
lines changed

.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("./utils");
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/Crt.Api/Middlewares/ReverseProxyMiddleware.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
using System.Linq;
77
using System.Net.Http;
88
using System.Threading.Tasks;
9+
using Microsoft.Extensions.Logging;
910

1011
namespace Crt.Api.Middlewares
1112
{
1213
public class ReverseProxyMiddleware
1314
{
1415
private HttpClient _httpClient;
1516
private readonly RequestDelegate _nextMiddleware;
17+
private readonly ILogger _logger;
1618

17-
public ReverseProxyMiddleware(RequestDelegate nextMiddleware)
19+
public ReverseProxyMiddleware(RequestDelegate nextMiddleware, ILogger<ReverseProxyMiddleware> logger)
1820
{
1921
_nextMiddleware = nextMiddleware;
22+
_logger = logger;
23+
2024
}
2125

2226
public async Task Invoke(HttpContext context, IGeoServerApi geoServerApi)
@@ -27,7 +31,7 @@ public async Task Invoke(HttpContext context, IGeoServerApi geoServerApi)
2731

2832
if (targetUri != null)
2933
{
30-
Console.WriteLine($"Proxy - {targetUri}");
34+
_logger.LogInformation($"Proxy - {targetUri}");
3135

3236
var targetRequestMessage = CreateTargetMessage(context, targetUri);
3337

api/Crt.Api/appsettings.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"AllowedHosts": "*",
33
"Constants": {
4-
"Version": "1.0.4.0",
4+
"Version": "1.0.5.0",
55
"SwaggerApiUrl": "/swagger/v1/swagger.json"
66
},
77
"Serilog": {
@@ -16,7 +16,14 @@
1616
{
1717
"Name": "Async",
1818
"Args": {
19-
"configure": [ { "Name": "Console" } ]
19+
"configure": [
20+
{
21+
"Name": "Console",
22+
"Args": {
23+
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
24+
}
25+
}
26+
]
2027
}
2128
}
2229
],

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.ChangeTracking;
44
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.Logging;
56
using System;
67
using System.Collections.Generic;
78
using System.Linq;
@@ -20,12 +21,14 @@ public partial class AppDbContext
2021

2122
public readonly CrtCurrentUser _currentUser;
2223
private readonly IConfiguration _config;
24+
private readonly ILogger<AppDbContext> _logger;
2325

24-
public AppDbContext(DbContextOptions<AppDbContext> options, CrtCurrentUser currentUser, IConfiguration config)
26+
public AppDbContext(DbContextOptions<AppDbContext> options, CrtCurrentUser currentUser, IConfiguration config, ILogger<AppDbContext> logger)
2527
: base(options)
2628
{
2729
_currentUser = currentUser;
2830
_config = config;
31+
_logger = logger;
2932
}
3033

3134
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
@@ -47,7 +50,8 @@ public override int SaveChanges()
4750
}
4851
catch (Exception e)
4952
{
50-
Console.WriteLine(e);
53+
string exceptionMessage = e.ToString();
54+
_logger.LogError($"AppDbContext exception: {exceptionMessage}");
5155
throw;
5256
}
5357

api/Crt.Hangfire/appsettings.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@
1616
{
1717
"Name": "Async",
1818
"Args": {
19-
"configure": [{ "Name": "Console" }]
19+
"configure": [
20+
{
21+
"Name": "Console",
22+
"Args": {
23+
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
24+
}
25+
}
26+
]
2027
}
2128
}
2229
],
23-
"Enrich": ["FromLogContext", "WithMachineName"]
30+
"Enrich": [
31+
"FromLogContext",
32+
"WithMachineName"
33+
]
2434
},
2535
"ConnectionStrings": {
2636
"CRT": "Server=(localdb)\\mssqllocaldb;Database=CMR_DEV;Trusted_Connection=True;MultipleActiveResultSets=true"
@@ -30,8 +40,8 @@
3040
"WorkerCount": 1
3141
},
3242
"JWT": {
33-
"Authority": "https://dev.oidc.gov.bc.ca/auth/realms/kmas316h",
34-
"Audience": "moti-idir-dev"
43+
"Authority": "https://dev.loginproxy.gov.bc.ca/auth/realms/moti-custom",
44+
"Audience": "account"
3545
},
3646
"ServiceAccount": {
3747
"User": "<ServiceAccount:User>",
@@ -43,4 +53,4 @@
4353
"ServiceClientId": "<service-client-id>",
4454
"ServiceClientSecret": "<service-client-secret>"
4555
}
46-
}
56+
}

api/Crt.HttpClients/HttpClientsServiceCollectionExtensions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ private static TimeSpan GetTimeout(IConfiguration config, string section)
4646
var seconds = config.GetValue<int>(section);
4747
if (seconds <= 0)
4848
{
49-
Console.WriteLine($"Config - Invalid {section} value: {seconds}");
5049
seconds = 90;
5150
}
5251

client/.env.development

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
BROWSER=none
22
REACT_APP_API_HOST=http://localhost:27238
3-
REACT_APP_SSO_CLIENT=moti-idir-dev
4-
REACT_APP_SSO_REALM=kmas316h
5-
REACT_APP_SSO_HOST=https://dev.oidc.gov.bc.ca/auth
3+
REACT_APP_SSO_CLIENT=crt-ui
4+
REACT_APP_SSO_REALM=moti-custom
5+
REACT_APP_SSO_HOST=https://dev.loginproxy.gov.bc.ca/auth
66
REACT_APP_DEFAULT_PAGE_SIZE_OPTIONS=2,4,16,200
77
REACT_APP_DEFAULT_PAGE_SIZE=15
88
REACT_APP_DWPBI_URL=https://dev-dwpbi.th.gov.bc.ca/reports/browse/CRT

openshift/configmaps/api-appsettings.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ objects:
2525
"Name": "Async",
2626
"Args": {
2727
"configure": [
28-
{ "Name": "Console" }
28+
{
29+
"Name": "Console",
30+
"Args": {
31+
"outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"
32+
}
33+
}
2934
]
3035
}
3136
},
@@ -51,7 +56,7 @@ objects:
5156
"WorkerCount": 1
5257
},
5358
"JWT": {
54-
"Authority": "https://dev.oidc.gov.bc.ca/auth/realms/<realmid>",
59+
"Authority": "https://dev.loginproxy.gov.bc.ca/auth/realms/<realmid>",
5560
"Audience": "<app-id>"
5661
},
5762
"ServiceAccount": {

0 commit comments

Comments
 (0)