Logging refactor
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using FirebaseAdmin;
|
||||
using Google.Apis.Auth.OAuth2;
|
||||
using Google.Cloud.Firestore;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
@@ -87,24 +86,10 @@ builder.Services.AddSingleton<SpreadsheetsResource.ValuesResource>(provider =>
|
||||
return valuesResource;
|
||||
});
|
||||
|
||||
|
||||
var fileName = "diunabi-admin-firebase.json";
|
||||
#if DEBUG
|
||||
fileName = "diunabi-admin-firebase-Development.json";
|
||||
#endif
|
||||
var credentialPath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
||||
System.Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credentialPath);
|
||||
FirebaseAdmin.FirebaseApp.Create(new AppOptions()
|
||||
{
|
||||
Credential = GoogleCredential.GetApplicationDefault()
|
||||
});
|
||||
builder.Services.AddSingleton(FirestoreDb.Create("diunabi-admin"));
|
||||
|
||||
builder.Services.AddSingleton<PluginManager>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// ✅ DODAJ SERILOG REQUEST LOGGING
|
||||
app.UseSerilogRequestLogging(options =>
|
||||
{
|
||||
options.MessageTemplate = "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms";
|
||||
@@ -113,20 +98,17 @@ app.UseSerilogRequestLogging(options =>
|
||||
diagnosticContext.Set("RequestHost", httpContext.Request.Host.Value);
|
||||
diagnosticContext.Set("RequestScheme", httpContext.Request.Scheme);
|
||||
|
||||
// ✅ POPRAW NULLABLE WARNING
|
||||
var userAgent = httpContext.Request.Headers.UserAgent.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(userAgent))
|
||||
{
|
||||
diagnosticContext.Set("UserAgent", userAgent);
|
||||
}
|
||||
|
||||
// Dodaj więcej użytecznych właściwości
|
||||
diagnosticContext.Set("RemoteIP", httpContext.Connection.RemoteIpAddress?.ToString() ?? "unknown");
|
||||
diagnosticContext.Set("RequestContentType", httpContext.Request.ContentType ?? "none");
|
||||
};
|
||||
});
|
||||
|
||||
// Załaduj pluginy - z logowaniem
|
||||
var pluginManager = app.Services.GetRequiredService<PluginManager>();
|
||||
var executablePath = Assembly.GetExecutingAssembly().Location;
|
||||
var executableDir = Path.GetDirectoryName(executablePath)!;
|
||||
|
||||
Reference in New Issue
Block a user