|
1 | | -using System; |
2 | | -using System.Linq; |
3 | | -using System.Threading; |
4 | | -using System.Threading.Tasks.Dataflow; |
5 | 1 | using Intent.Engine; |
6 | 2 | using Intent.Modules.AspNetCore.Logging.Serilog.Settings; |
7 | 3 | using Intent.Modules.AspNetCore.Logging.Serilog.Templates; |
| 4 | +using Intent.Modules.AspNetCore.Logging.Serilog.Templates.BoundedLoggingDestructuringPolicy; |
8 | 5 | using Intent.Modules.Common; |
9 | 6 | using Intent.Modules.Common.CSharp.AppStartup; |
10 | 7 | using Intent.Modules.Common.CSharp.Builder; |
|
16 | 13 | using Intent.Plugins.FactoryExtensions; |
17 | 14 | using Intent.RoslynWeaver.Attributes; |
18 | 15 | using Intent.Templates; |
| 16 | +using System; |
| 17 | +using System.Linq; |
| 18 | +using System.Threading; |
| 19 | +using System.Threading.Tasks.Dataflow; |
19 | 20 |
|
20 | 21 | [assembly: DefaultIntentManaged(Mode.Fully)] |
21 | 22 | [assembly: IntentTemplate("Intent.ModuleBuilder.Templates.FactoryExtension", Version = "1.0")] |
@@ -85,10 +86,19 @@ private static void RegisterSerilogConfiguration(IApplication application) |
85 | 86 | programTemplate.ProgramFile.ConfigureHostBuilderChainStatement("UseSerilog", ["context", "services", "configuration"], |
86 | 87 | (lambdaBlock, parameters) => |
87 | 88 | { |
88 | | - lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration") |
89 | | - .AddChainStatement("ReadFrom.Configuration(context.Configuration)") |
90 | | - .AddChainStatement("ReadFrom.Services(services)") |
91 | | - .AddChainStatement($"Destructure.With(new {programTemplate.GetBoundedLoggingDestructuringPolicyTemplateName()}())")); |
| 89 | + if (programTemplate.OutputTarget.FindTemplateInstance(BoundedLoggingDestructuringPolicyTemplate.TemplateId) != null) |
| 90 | + { |
| 91 | + lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration") |
| 92 | + .AddChainStatement("ReadFrom.Configuration(context.Configuration)") |
| 93 | + .AddChainStatement("ReadFrom.Services(services)") |
| 94 | + .AddChainStatement($"Destructure.With(new {programTemplate.GetBoundedLoggingDestructuringPolicyTemplateName()}())")); |
| 95 | + } |
| 96 | + else |
| 97 | + { |
| 98 | + lambdaBlock.WithExpressionBody(new CSharpMethodChainStatement("configuration") |
| 99 | + .AddChainStatement("ReadFrom.Configuration(context.Configuration)") |
| 100 | + .AddChainStatement("ReadFrom.Services(services)")); |
| 101 | + } |
92 | 102 | }); |
93 | 103 | }, 10); |
94 | 104 | } |
|
0 commit comments