fixing dotnets terrible logging

This commit is contained in:
2023-12-05 15:30:33 -07:00
parent a77c001601
commit e8aef7357a
16 changed files with 134 additions and 95 deletions

View File

@@ -16,7 +16,7 @@
@inject CanvasService canvas
@inject CoursePlanner planner
@inject QuizEditorContext quizContext
@inject ILogger<QuizFormPage> logger
@inject MyLogger<QuizFormPage> logger
@inject NavigationManager Navigation
@code {
@@ -45,12 +45,12 @@
if (loading)
{
loading = false;
logger.LogInformation($"loading quiz {CourseName} {QuizName}");
logger.Log($"loading quiz {CourseName} {QuizName}");
if (planner.LocalCourse == null)
{
var courses = await fileStorageManager.LoadSavedCourses();
planner.LocalCourse = courses.First(c => c.Settings.Name == CourseName);
logger.LogInformation($"set course to '{planner.LocalCourse?.Settings.Name}'");
logger.Log($"set course to '{planner.LocalCourse?.Settings.Name}'");
}
if (quizContext.Quiz == null)
@@ -62,7 +62,7 @@
.FirstOrDefault(q => q.Name == QuizName);
quizContext.Quiz = quiz;
logger.LogInformation($"set quiz to '{quizContext.Quiz?.Name}'");
logger.Log($"set quiz to '{quizContext.Quiz?.Name}'");
}
StateHasChanged();

View File

@@ -15,6 +15,8 @@ global using Management.Web.Shared.Components.Forms;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using dotenv.net;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Hosting.Server.Features;
DotEnv.Load();
@@ -60,6 +62,8 @@ builder.Services.AddSignalR(e =>
e.MaximumReceiveMessageSize = 102400000;
});
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -79,4 +83,14 @@ app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
app.Start();
var addresses = app.Services.GetService<IServer>().Features.Get<IServerAddressesFeature>().Addresses;
foreach (var address in addresses)
{
Console.WriteLine("Running at: " + address);
}
app.WaitForShutdown();

View File

@@ -167,31 +167,16 @@
<div class="flex-grow-1 d-flex flex-column">
@if (assignmentContext.Assignment != null)
{
<div class="m-1">
<label class="form-label">
Name
</label>
<input class="form-control" @bind="name" @oninput="handleNameChange" />
</div>
<ButtonSelect
@* <ButtonSelect
Label="Assignment Group"
Options="planner.LocalCourse?.Settings.AssignmentGroups"
GetName="(g) => g?.Name"
OnSelect="(g) => setAssignmentGroup(g)"
SelectedOption="selectedAssignmentGroup"
/>
/> *@
<div class="m-1 flex-grow-1">
<AssignmentMarkdownEditor />
</div>
@* <div class="container">
<RubricMarkdownEditor />
<hr>
<div class="mx-5 px-5">
<SubmissionTypeSelector />
</div>
</div> *@
}
</div>

View File

@@ -55,15 +55,6 @@
{
StateHasChanged();
}
@* if (assignmentContext.Assignment != null)
{
var newAssignment = assignmentContext.Assignment with
{
Description = newRawAssignment
};
assignmentContext.SaveAssignment(newAssignment);
} *@
}
StateHasChanged();
}

View File

@@ -3,7 +3,7 @@
@inject FileStorageManager fileStorageManager
@inject CoursePlanner planner
@inject NavigationManager Navigation
@inject ILogger<CurrentFiles> logger
@inject MyLogger<CurrentFiles> logger
@code
{
@@ -17,10 +17,8 @@
void handleClick(MouseEventArgs e, LocalCourse course)
{
@* logger.LogInformation("here"); *@
planner.LocalCourse = course;
Navigation.NavigateTo("/course/" + course.Settings.Name);
Console.WriteLine("navigated to course detail");
}
}

View File

@@ -5,7 +5,7 @@
@inject NavigationManager Navigation
@inject AssignmentEditorContext assignmentContext
@inject ILogger<AssignmentInDay> logger
@inject MyLogger<AssignmentInDay> logger
@inherits DroppableAssignment
@code {
@@ -38,7 +38,7 @@
{
assignmentContext.Assignment = Assignment;
Navigation.NavigateTo("/course/" + planner.LocalCourse.Settings.Name + "/assignment/" + Assignment.Name);
logger.LogInformation("navigating to assignment page");
logger.Log("navigating to assignment page");
}
}
}

View File

@@ -2,8 +2,8 @@
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Default": "Error",
"Microsoft.AspNetCore": "Error"
}
}
}

View File

@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Default": "Error",
"Microsoft.AspNetCore": "Warning"
}
},