From 7af0c6f1a74fc7ebe55acfc6167e2d8077616d98 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 1 May 2024 01:57:01 +0200 Subject: [PATCH] [backend/drive] Improve VIPS logger --- .../Core/Extensions/WebApplicationExtensions.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs b/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs index a6c74837..a2c25817 100644 --- a/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/WebApplicationExtensions.cs @@ -196,16 +196,15 @@ public static class WebApplicationExtensions SixLabors.ImageSharp.Configuration.Default.MemoryAllocator = MemoryAllocator.Create(new MemoryAllocatorOptions { AllocationLimitMegabytes = 20 }); - - NetVips.Log.SetLogHandler("VIPS", NetVips.Enums.LogLevelFlags.Warning, null); - NetVips.Log.SetLogHandler("VIPS", NetVips.Enums.LogLevelFlags.Error, (domain, _, message) => - { - app.Logger.LogWarning("libvips error: {domain} - {message}", domain, message); - }); - app.Logger.LogInformation("Initializing application, please wait..."); + var logger = app.Services.GetRequiredService>(); + NetVips.Log.SetLogHandler("VIPS", NetVips.Enums.LogLevelFlags.Warning | NetVips.Enums.LogLevelFlags.Error, + VipsLogDelegate); return instanceConfig; + + void VipsLogDelegate(string domain, NetVips.Enums.LogLevelFlags _, string message) => + logger.LogWarning("libvips: {domain} - {message}", domain, message); } public static void SetKestrelUnixSocketPermissions(this WebApplication app)