Resolve a critical error in new logging code (#231)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace gaseous_server.Classes
|
||||
@@ -138,4 +137,3 @@ namespace gaseous_server.Classes
|
||||
state.TryGetValue(name, out AsyncLocal<object> data) ? data.Value : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -76,6 +76,8 @@ namespace gaseous_server.Classes
|
||||
}
|
||||
|
||||
string correlationId;
|
||||
try
|
||||
{
|
||||
if (CallContext.GetData("CorrelationId").ToString() == null)
|
||||
{
|
||||
correlationId = "";
|
||||
@@ -84,8 +86,15 @@ namespace gaseous_server.Classes
|
||||
{
|
||||
correlationId = CallContext.GetData("CorrelationId").ToString();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
correlationId = "";
|
||||
}
|
||||
|
||||
string callingProcess;
|
||||
try
|
||||
{
|
||||
if (CallContext.GetData("CallingProcess").ToString() == null)
|
||||
{
|
||||
callingProcess = "";
|
||||
@@ -94,6 +103,11 @@ namespace gaseous_server.Classes
|
||||
{
|
||||
callingProcess = CallContext.GetData("CallingProcess").ToString();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
callingProcess = "";
|
||||
}
|
||||
|
||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||
string sql = "DELETE FROM ServerLogs WHERE EventTime < @EventRententionDate; INSERT INTO ServerLogs (EventTime, EventType, Process, Message, Exception, CorrelationId, CallingProcess) VALUES (@EventTime, @EventType, @Process, @Message, @Exception, @correlationid, @callingprocess);";
|
||||
|
@@ -18,7 +18,7 @@ namespace gaseous_server.Controllers
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class FilterController : ControllerBase
|
||||
public class FilterController : Controller
|
||||
{
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
private readonly SignInManager<ApplicationUser> _signInManager;
|
||||
|
@@ -22,7 +22,7 @@ namespace gaseous_server.Controllers
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class GamesController : ControllerBase
|
||||
public class GamesController : Controller
|
||||
{
|
||||
[MapToApiVersion("1.0")]
|
||||
[HttpGet]
|
||||
|
@@ -22,7 +22,7 @@ namespace gaseous_server.Controllers
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class RomsController : ControllerBase
|
||||
public class RomsController : Controller
|
||||
{
|
||||
[MapToApiVersion("1.0")]
|
||||
[MapToApiVersion("1.1")]
|
||||
|
@@ -18,7 +18,7 @@ namespace gaseous_server.Controllers
|
||||
[ApiVersion("1.0")]
|
||||
[ApiVersion("1.1")]
|
||||
[Authorize]
|
||||
public class SignaturesController : ControllerBase
|
||||
public class SignaturesController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the current signature counts from the database
|
||||
|
@@ -295,29 +295,22 @@ using (var scope = app.Services.CreateScope())
|
||||
await roleManager.CreateAsync(applicationRole, CancellationToken.None);
|
||||
}
|
||||
}
|
||||
|
||||
// // set up administrator account
|
||||
// var userManager = scope.ServiceProvider.GetRequiredService<UserStore>();
|
||||
// if (await userManager.FindByNameAsync("admin@localhost", CancellationToken.None) == null)
|
||||
// {
|
||||
// ApplicationUser adminUser = new ApplicationUser{
|
||||
// Id = Guid.NewGuid().ToString(),
|
||||
// Email = "admin@localhost",
|
||||
// NormalizedEmail = "ADMIN@LOCALHOST",
|
||||
// EmailConfirmed = true,
|
||||
// UserName = "administrator",
|
||||
// NormalizedUserName = "ADMINISTRATOR"
|
||||
// };
|
||||
|
||||
// //set user password
|
||||
// PasswordHasher<ApplicationUser> ph = new PasswordHasher<ApplicationUser>();
|
||||
// adminUser.PasswordHash = ph.HashPassword(adminUser, "letmein");
|
||||
|
||||
// await userManager.CreateAsync(adminUser, CancellationToken.None);
|
||||
// await userManager.AddToRoleAsync(adminUser, "Admin", CancellationToken.None);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
// set the correlation id
|
||||
string correlationId = Guid.NewGuid().ToString();
|
||||
CallContext.SetData("CorrelationId", correlationId);
|
||||
CallContext.SetData("CallingProcess", context.Request.Method + ": " + context.Request.Path);
|
||||
|
||||
context.Response.Headers.Add("x-correlation-id", correlationId.ToString());
|
||||
await next();
|
||||
});
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseDefaultFiles();
|
||||
|
@@ -21,6 +21,6 @@ ADD INDEX `idx_SecondaryColumn` (`ThemesId` ASC) VISIBLE;
|
||||
|
||||
ALTER TABLE `ServerLogs`
|
||||
ADD COLUMN `CorrelationId` VARCHAR(45) NULL AFTER `Exception`,
|
||||
ADD COLUMN `CallingProcess` VARCHAR(45) NULL AFTER `CorrelationId`,
|
||||
ADD COLUMN `CallingProcess` VARCHAR(255) NULL AFTER `CorrelationId`,
|
||||
ADD INDEX `idx_CorrelationId` (`CorrelationId` ASC) VISIBLE,
|
||||
ADD INDEX `idx_CallingProcess` (`CallingProcess` ASC) VISIBLE;
|
Reference in New Issue
Block a user