From 0670bdd97ef45fdcf16d4fa20f8e1ed0f0c66be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Sun, 1 Oct 2023 00:10:16 +0200 Subject: [PATCH] adds some logging befor uploading a file --- PiwigoDirectorySync/Program.cs | 2 +- PiwigoDirectorySync/Services/ImageSynchronizer.cs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/PiwigoDirectorySync/Program.cs b/PiwigoDirectorySync/Program.cs index 38f1ee9..1d2401c 100644 --- a/PiwigoDirectorySync/Program.cs +++ b/PiwigoDirectorySync/Program.cs @@ -17,7 +17,7 @@ const string outputTemplateFile = "[{Timestamp:HH:mm:ss} {Level}] {SourceContext Log.Logger = new LoggerConfiguration().MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) .MinimumLevel.Override("System", LogEventLevel.Warning) - .MinimumLevel.Override("Piwigo.Client", LogEventLevel.Warning) + .MinimumLevel.Override("Piwigo.Client", LogEventLevel.Debug) .Enrich.FromLogContext() .WriteTo.Console(LogEventLevel.Information, outputTemplateConsole, theme: AnsiConsoleTheme.Code) .WriteTo.File("logs/PiwigoDirectorySync.txt", LogEventLevel.Debug, outputTemplateFile, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 90) diff --git a/PiwigoDirectorySync/Services/ImageSynchronizer.cs b/PiwigoDirectorySync/Services/ImageSynchronizer.cs index c655438..5a8e933 100644 --- a/PiwigoDirectorySync/Services/ImageSynchronizer.cs +++ b/PiwigoDirectorySync/Services/ImageSynchronizer.cs @@ -217,6 +217,11 @@ internal class ImageSynchronizer : IImageSynchronizer foreach (var imageEntity in imagesToUpload) { var fileInfo = new FileInfo(Path.Combine(piwigoServer.RootDirectory, imageEntity.FilePath)); + + var fileSizeInKb = fileInfo.Length / 1024f; + _logger.Information("Uploading image {ImageFilePath} ({ImageId}) to piwigo server with id {ImageServerImageId} ({Size} KiB)", imageEntity.FilePath, imageEntity.Id, + imageEntity.ServerImageId, fileSizeInKb); + var imageUpload = GetImageUpload(imageEntity, fileInfo.CreationTime); var imageUploaded = await piwigoClient.UploadImageAsync(fileInfo, imageUpload, ct);