This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* can insert logs into the database * update log code * fixed * fixed * adding logger manifests * prep code for deploying * add db * fix * rename * rename * changes made to these files * added ui from master * db updates * logger context updates * format code * changed the logger alpha memory * fixed logger tests to include a closed connection * increase memory for logger prod * fixed the readme to reflect logger application * removed using system * removed logger.LogInformation * removed package reference and using system * added gitignore .DS_Store * format of logger tests is fixed * format of program is fixed * .DS_Store banished! * adding db-service-dm-logger * Delete .gitignore * fixed the naming conventions for unit test * Update subscribers/logs/logger/AppService.cs Co-Authored-By: tobiasbrown <[email protected]> * Update subscribers/logs/logger.tests/logger.tests.csproj Co-Authored-By: tobiasbrown <[email protected]> * fixed slack tests * fixed part 2 slack * fixed slack pt3 * Update subscribers/logs/logger/AppService.cs Co-Authored-By: tobiasbrown <[email protected]> * Update subscribers/logs/logger/AppService.cs Co-Authored-By: tobiasbrown <[email protected]> * Update subscribers/logs/logger/AppService.cs Co-Authored-By: tobiasbrown <[email protected]> * indentation fixed * Update subscribers/logs/logger/MessageProcessor.cs Co-Authored-By: tobiasbrown <[email protected]> * Update subscribers/logs/logger/MessageProcessor.cs Co-Authored-By: tobiasbrown <[email protected]>
- Loading branch information
1 parent
e1f1e2c
commit 54f3611
Showing
27 changed files
with
862 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
**/obj/**/*.* | ||
**/node_modules/**/* | ||
**/build/**/* | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
applications: | ||
- name: dm-alpha-logger | ||
buildpack: dotnet_core_buildpack | ||
path: ../subscribers/logs/logger | ||
health-check-type: process | ||
instances: 1 | ||
memory: 50M | ||
disk_quota: 100M | ||
services: | ||
- ups-dm-alpha-logger | ||
- db-service-dm-alpha-logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
applications: | ||
- name: dm-dev-logger | ||
buildpack: dotnet_core_buildpack | ||
path: ../subscribers/logs/logger | ||
health-check-type: process | ||
instances: 1 | ||
memory: 50M | ||
disk_quota: 100M | ||
services: | ||
- ups-dm-dev-logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
applications: | ||
- name: dm-pc-logger | ||
buildpack: dotnet_core_buildpack | ||
path: ../subscribers/logs/logger | ||
health-check-type: process | ||
instances: 1 | ||
memory: 50M | ||
disk_quota: 100M | ||
services: | ||
- ups-dm-pc-logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
applications: | ||
- name: dm-logger | ||
buildpack: dotnet_core_buildpack | ||
path: ../subscribers/logs/logger | ||
health-check-type: process | ||
instances: 1 | ||
memory: 128M | ||
disk_quota: 100M | ||
services: | ||
- ups-dm-logger | ||
- db-service-dm-logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
applications: | ||
- name: dm-rc-logger | ||
buildpack: dotnet_core_buildpack | ||
path: ../subscribers/logs/logger | ||
health-check-type: process | ||
instances: 1 | ||
memory: 50M | ||
disk_quota: 100M | ||
services: | ||
- ups-dm-rc-logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using Xunit; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using Moq; | ||
using Newtonsoft.Json; | ||
using Microsoft.Data.Sqlite; | ||
using Dta.Marketplace.Subscribers.Logger.Worker; | ||
using Amazon.SQS.Model; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Dta.Marketplace.Subscribers.Logger.Worker.Logger.Tests { | ||
|
||
public class LoggerTests { | ||
|
||
[Fact] | ||
public void Can_Log_Information_Message() { | ||
|
||
// Arrange | ||
var logger = new Mock<ILoggerAdapter<AppService>>(); | ||
var dbSet = new Mock<DbSet<LogEntry>>(); | ||
var connection = new SqliteConnection("DataSource=:memory:"); | ||
connection.Open(); | ||
try { | ||
//In-memory database only exists while the connection is open | ||
var options = new DbContextOptionsBuilder<LoggerContext>() | ||
.UseSqlite(connection) | ||
.Options; | ||
|
||
//create schema in the database | ||
using (var context = new LoggerContext(options)) { | ||
context.Database.EnsureCreated(); | ||
} | ||
|
||
var json = JsonConvert.SerializeObject(new { | ||
foo = "bar" | ||
}); | ||
|
||
// Act | ||
using (var context = new LoggerContext(options)) { | ||
var messageProcessor = new MessageProcessor(logger.Object, context); | ||
messageProcessor.Process(new Message { | ||
Body = json | ||
}); | ||
} | ||
|
||
// Assert | ||
using (var context = new LoggerContext(options)) { | ||
logger.Verify(l => l.LogInformation(json), Times.Once); | ||
} | ||
} finally { | ||
connection.Close(); | ||
} | ||
} | ||
|
||
|
||
[Fact] | ||
public void Can_Log_Exception() { | ||
// Arrange | ||
var logger = new Mock<ILoggerAdapter<AppService>>(); | ||
var dbSet = new Mock<DbSet<LogEntry>>(); | ||
var connection = new SqliteConnection("DataSource=:memory:"); | ||
connection.Open(); | ||
try { | ||
var options = new DbContextOptionsBuilder<LoggerContext>() | ||
.UseSqlite(connection) | ||
.Options; | ||
|
||
using (var context = new LoggerContext(options)) { | ||
context.Database.EnsureCreated(); | ||
} | ||
var json = JsonConvert.SerializeObject(new { | ||
foo = "" | ||
}); | ||
|
||
//Act | ||
using (var context = new LoggerContext(options)) { | ||
var messageProcessor = new MessageProcessor(logger.Object, context); | ||
messageProcessor.Process(null); | ||
} | ||
//Assert | ||
using (var context = new LoggerContext(options)) { | ||
logger.Verify(l => l.LogError(It.IsAny<string>(), It.IsAny<Exception>()), Times.Once); | ||
} | ||
} finally { | ||
connection.Close(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="../logger/worker.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="AWSSDK.SQS" Version="3.3.100.40" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" /> | ||
<PackageReference Include="Moq" Version="4.12.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<AssemblyName>Logger.Worker.logger.Tests</AssemblyName> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace Dta.Marketplace.Subscribers.Logger.Worker { | ||
public class AppConfig { | ||
public string AwsSqsRegion { get; set; } = "ap-southeast-2"; | ||
public string AwsSqsQueueUrl { get; set; } | ||
public string AwsSqsServiceUrl { get; set; } | ||
public string AwsSqsAccessKeyId { get; set; } | ||
public string AwsSqsSecretAccessKey { get; set; } | ||
public int AwsSqsLongPollTimeInSeconds { get; set; } = 20; | ||
public int WorkIntervalInSeconds { get; set; } = 60; | ||
public string SentryDsn { get; set; } | ||
public string ConnectionString { get; set; } | ||
} | ||
} |
Oops, something went wrong.