示例#1
0
文件: Program.cs 项目: husains/bicep
        public static async Task <int> Main(string[] args)
        {
            string profilePath = DirHelper.GetTempPath();

            ProfileOptimization.SetProfileRoot(profilePath);
            ProfileOptimization.StartProfile("bicep.profile");
            Console.OutputEncoding = TemplateEmitter.UTF8EncodingWithoutBom;

            BicepDeploymentsInterop.Initialize();

            if (FeatureProvider.TracingEnabled)
            {
                Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
            }

            // this event listener picks up SDK events and writes them to Trace.WriteLine()
            using (FeatureProvider.TracingEnabled ? AzureEventSourceListenerFactory.Create(FeatureProvider.TracingVerbosity) : null)
            {
                var program = new Program(new InvocationContext(
                                              new AzResourceTypeLoader(),
                                              Console.Out,
                                              Console.Error,
                                              features: null,
                                              clientFactory: null));

                // this must be awaited so dispose of the listener occurs in the continuation
                // rather than the sync part at the beginning of RunAsync()
                return(await program.RunAsync(args));
            }
        }
示例#2
0
 public void HeadersShouldBeRemoved()
 {
     AzureEventSourceListenerFactory.GetFormattedMessageWithoutHeaders(
         Features.TraceVerbosity.Basic,
         AzureCoreEventSource,
         FormatString,
         SampleNamesWithHeaders,
         SampleValuesWithHeaders).Should().Be("1--><--two");
 }
示例#3
0
 public void NonHeaderEventShouldReturnNull()
 {
     AzureEventSourceListenerFactory.GetFormattedMessageWithoutHeaders(
         Features.TraceVerbosity.Basic,
         AzureCoreEventSource,
         FormatString,
         SampleNamesWithoutHeaders,
         SampleValuesWithoutHeaders).Should().BeNull();
 }
示例#4
0
        public async Task RunAsync(CancellationToken cancellationToken)
        {
            await server.Initialize(cancellationToken);

            server.LogInfo($"Running on processId {Environment.ProcessId}");

            if (FeatureProvider.TracingEnabled)
            {
                Trace.Listeners.Add(new ServerLogTraceListener(server));
            }

            using (FeatureProvider.TracingEnabled ? AzureEventSourceListenerFactory.Create(FeatureProvider.TracingVerbosity) : null)
            {
                var scheduler = server.GetRequiredService <IModuleRestoreScheduler>();
                scheduler.Start();

                await server.WaitForExit;
            }
        }