start migrating output logging

This commit is contained in:
Greg Oliver 2019-03-12 11:03:28 +00:00
Родитель aae0fdb7f6
Коммит f7d9f376d0
3 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -16,6 +16,7 @@ namespace nsgFunc
[BlobTrigger("%blobContainerName%/resourceId=/SUBSCRIPTIONS/{subId}/RESOURCEGROUPS/{resourceGroup}/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/{nsgName}/y={blobYear}/m={blobMonth}/d={blobDay}/h={blobHour}/m={blobMinute}/macAddress={mac}/PT1H.json", Connection = "%nsgSourceDataAccount%")]CloudBlockBlob myBlob,
[Table("checkpoints", Connection = "AzureWebJobsStorage")] CloudTable checkpointTable,
Binder nsgDataBlobBinder,
Binder errorRecordBinder,
string subId, string resourceGroup, string nsgName, string blobYear, string blobMonth, string blobDay, string blobHour, string blobMinute, string mac,
ExecutionContext executionContext,
ILogger log)
@ -102,7 +103,7 @@ namespace nsgFunc
try
{
int bytesSent = await Util.SendMessagesDownstreamAsync(nsgMessagesString, executionContext, log);
int bytesSent = await Util.SendMessagesDownstreamAsync(nsgMessagesString, executionContext, errorRecordBinder, log);
log.LogDebug($"Sending {nsgMessagesString.Length} bytes (denormalized to {bytesSent} bytes) downstream via output binding {outputBinding}.");
}
catch (Exception ex)

Просмотреть файл

@ -24,7 +24,7 @@ namespace nsgFunc
return result;
}
public static async Task<int> SendMessagesDownstreamAsync(string nsgMessagesString, ExecutionContext executionContext, ILogger log)
public static async Task<int> SendMessagesDownstreamAsync(string nsgMessagesString, ExecutionContext executionContext, Binder errorRecordBinder, ILogger log)
{
//
// nsgMessagesString looks like this:
@ -78,6 +78,16 @@ namespace nsgFunc
// }
//
string logIncomingJSON = Util.GetEnvironmentVariable("logIncomingJSON");
Boolean flag;
if (Boolean.TryParse(logIncomingJSON, out flag))
{
if (flag)
{
Util.logErrorRecord(newClientContent, errorRecordBinder, log).Wait();
}
}
int bytesSent = 0;
switch (outputBinding)
{

Просмотреть файл

@ -189,16 +189,6 @@ namespace nsgFunc
NSGFlowLogRecords logs = JsonConvert.DeserializeObject<NSGFlowLogRecords>(newClientContent);
string logIncomingJSON = Util.GetEnvironmentVariable("logIncomingJSON");
Boolean flag;
if (Boolean.TryParse(logIncomingJSON, out flag))
{
if (flag)
{
Util.logErrorRecord(newClientContent, errorRecordBinder, log).Wait();
}
}
string cefRecordBase = "";
foreach (var record in logs.records)
{