Skip to content

Commit a59b5af

Browse files
committed
Adding status messages for JSON and Cosmos
1 parent b35e645 commit a59b5af

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Extensions/Cosmos/Microsoft.DataTransfer.CosmosExtension/CosmosDataSourceExtension.cs

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Azure.Cosmos;
44
using Microsoft.DataTransfer.Interfaces;
55
using Microsoft.Extensions.Configuration;
6+
using System;
67

78
namespace Microsoft.DataTransfer.CosmosExtension
89
{
@@ -30,6 +31,7 @@ public async IAsyncEnumerable<IDataItem> ReadAsync(IConfiguration config, [Enume
3031
requestOptions.PartitionKey = new PartitionKey(settings.PartitionKey);
3132
}
3233

34+
Console.WriteLine($"Reading from {settings.Database}.{settings.Container}");
3335
using FeedIterator<Dictionary<string, object?>> feedIterator = GetFeedIterator<Dictionary<string, object?>>(settings, container, requestOptions);
3436
while (feedIterator.HasMoreResults)
3537
{

Extensions/Json/Microsoft.DataTransfer.JsonExtension/JsonDataSinkExtension.cs

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.ComponentModel.Composition;
33
using System.Text.Json;
44
using Microsoft.Extensions.Configuration;
5+
using System;
56
using Microsoft.DataTransfer.JsonExtension.Settings;
67

78
namespace Microsoft.DataTransfer.JsonExtension
@@ -18,6 +19,7 @@ public async Task WriteAsync(IAsyncEnumerable<IDataItem> dataItems, IConfigurati
1819

1920
if (settings.FilePath != null)
2021
{
22+
Console.WriteLine($"Writing to file '{settings.FilePath}'");
2123
await using var stream = File.Create(settings.FilePath);
2224
await using var writer = new Utf8JsonWriter(stream, new JsonWriterOptions
2325
{
@@ -31,6 +33,7 @@ public async Task WriteAsync(IAsyncEnumerable<IDataItem> dataItems, IConfigurati
3133
}
3234

3335
writer.WriteEndArray();
36+
Console.WriteLine($"Completed writing data to file '{settings.FilePath}'");
3437
}
3538
}
3639

Extensions/Json/Microsoft.DataTransfer.JsonExtension/JsonDataSourceExtension.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.DataTransfer.Interfaces;
66
using Microsoft.DataTransfer.JsonExtension.Settings;
77
using Microsoft.Extensions.Configuration;
8+
using System;
89

910
namespace Microsoft.DataTransfer.JsonExtension
1011
{
@@ -21,6 +22,7 @@ public async IAsyncEnumerable<IDataItem> ReadAsync(IConfiguration config, [Enume
2122
{
2223
if (File.Exists(settings.FilePath))
2324
{
25+
Console.WriteLine($"Reading file '{settings.FilePath}'");
2426
var list = await ReadFileAsync(cancellationToken, settings.FilePath);
2527

2628
if (list != null)
@@ -33,8 +35,11 @@ public async IAsyncEnumerable<IDataItem> ReadAsync(IConfiguration config, [Enume
3335
}
3436
else if (Directory.Exists(settings.FilePath))
3537
{
36-
foreach (string filePath in Directory.GetFiles(settings.FilePath, "*.json", SearchOption.AllDirectories).OrderBy(f => f))
38+
string[] files = Directory.GetFiles(settings.FilePath, "*.json", SearchOption.AllDirectories);
39+
Console.WriteLine($"Reading {files.Length} files from '{settings.FilePath}'");
40+
foreach (string filePath in files.OrderBy(f => f))
3741
{
42+
Console.WriteLine($"Reading file '{filePath}'");
3843
var list = await ReadFileAsync(cancellationToken, filePath);
3944

4045
if (list != null)
@@ -46,6 +51,7 @@ public async IAsyncEnumerable<IDataItem> ReadAsync(IConfiguration config, [Enume
4651
}
4752
}
4853
}
54+
Console.WriteLine($"Completed reading '{settings.FilePath}'");
4955
}
5056
}
5157

@@ -76,6 +82,12 @@ public async IAsyncEnumerable<IDataItem> ReadAsync(IConfiguration config, [Enume
7682
{
7783
// single item failed
7884
}
85+
86+
if (!list.Any())
87+
{
88+
Console.WriteLine($"No records read from '{filePath}'");
89+
}
90+
7991
return list;
8092
}
8193
}

0 commit comments

Comments
 (0)