Skip to content

Commit 4fd10b9

Browse files
authored
remove delegate (#809)
Signed-off-by: Maddy Koripalli <makoripa@microsoft.com>
1 parent 42d82ea commit 4fd10b9

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

test-outofproc/MultiFunctionTrigger.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4-
using System;
54
using System.Collections.Generic;
65
using DotnetIsolatedTests.Common;
76
using Microsoft.Extensions.Logging;
@@ -16,15 +15,15 @@ namespace DotnetIsolatedTests
1615
/// </summary>
1716
public static class MultiFunctionTrigger
1817
{
19-
private static readonly Action<ILogger, string, Exception> _loggerMessage = LoggerMessage.Define<string>(LogLevel.Information, eventId: new EventId(0, "INFO"), formatString: "{Message}");
2018

2119
[Function(nameof(MultiFunctionTrigger1))]
2220
public static void MultiFunctionTrigger1(
2321
[SqlTrigger("[dbo].[Products]", "SqlConnectionString")]
2422
IReadOnlyList<SqlChange<Product>> products,
2523
FunctionContext context)
2624
{
27-
_loggerMessage(context.GetLogger("ProductsTriggerWithValidation"), "Trigger1 Changes: " + Utils.JsonSerializeObject(products), null);
25+
ILogger logger = context.GetLogger("MultiFunctionTrigger1");
26+
logger.LogInformation("Trigger1 Changes: " + Utils.JsonSerializeObject(products), null);
2827
}
2928

3029
[Function(nameof(MultiFunctionTrigger2))]
@@ -33,7 +32,8 @@ public static void MultiFunctionTrigger2(
3332
IReadOnlyList<SqlChange<Product>> products,
3433
FunctionContext context)
3534
{
36-
_loggerMessage(context.GetLogger("ProductsTriggerWithValidation"), "Trigger2 Changes: " + Utils.JsonSerializeObject(products), null);
35+
ILogger logger = context.GetLogger("MultiFunctionTrigger1");
36+
logger.LogInformation("Trigger2 Changes: " + Utils.JsonSerializeObject(products), null);
3737
}
3838
}
3939
}

test-outofproc/ProductsTriggerWithValidation.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ namespace DotnetIsolatedTests
1212
{
1313
public static class ProductsTriggerWithValidation
1414
{
15-
private static readonly Action<ILogger, string, Exception> _loggerMessage = LoggerMessage.Define<string>(LogLevel.Information, eventId: new EventId(0, "INFO"), formatString: "{Message}");
16-
1715
/// <summary>
1816
/// Simple trigger function with additional logic to allow for verifying that the expected number
1917
/// of changes was received in each batch.
@@ -24,13 +22,14 @@ public static void Run(
2422
IReadOnlyList<SqlChange<Product>> changes,
2523
FunctionContext context)
2624
{
25+
ILogger logger = context.GetLogger("ProductsTriggerWithValidation");
2726
string expectedMaxBatchSize = Environment.GetEnvironmentVariable("TEST_EXPECTED_MAX_BATCH_SIZE");
2827
if (!string.IsNullOrEmpty(expectedMaxBatchSize) && int.Parse(expectedMaxBatchSize, null) != changes.Count)
2928
{
3029
throw new InvalidOperationException($"Invalid max batch size, got {changes.Count} changes but expected {expectedMaxBatchSize}");
3130
}
3231
// The output is used to inspect the trigger binding parameter in test methods.
33-
_loggerMessage(context.GetLogger("ProductsTriggerWithValidation"), "SQL Changes: " + Utils.JsonSerializeObject(changes), null);
32+
logger.LogInformation("SQL Changes: " + Utils.JsonSerializeObject(changes), null);
3433
}
3534
}
3635
}

test-outofproc/TriggerWithException.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public static class TriggerWithException
2323
public static void Run(
2424
[SqlTrigger("[dbo].[Products]", "SqlConnectionString")]
2525
IReadOnlyList<SqlChange<Product>> changes,
26-
ILogger logger)
26+
FunctionContext context)
2727
{
28+
ILogger logger = context.GetLogger("TriggerWithException");
2829
if (!threwException)
2930
{
3031
threwException = true;

0 commit comments

Comments
 (0)