adds some logging befor uploading a file
All checks were successful
PiwigoDirectorySync/pipeline/head This commit looks good

This commit is contained in:
Philipp Häfelfinger 2023-10-01 00:10:16 +02:00
parent 8e00c230fc
commit 0670bdd97e
2 changed files with 6 additions and 1 deletions

View File

@ -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)

View File

@ -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);