/// <summary> /// Adds a Functions Framework console logger, either using a "single line per log entry" plain text format or a JSON format, /// depending on the execution environment. /// </summary> /// <param name="builder">The logging builder to add the logger to.</param> /// <param name="context">The context of the web host builder being configured.</param> /// <returns>The original builder, for method chaining.</returns> public static ILoggingBuilder AddFunctionsConsoleLogging(this ILoggingBuilder builder, WebHostBuilderContext context) { var options = FunctionsFrameworkOptions.FromConfiguration(context.Configuration); ILoggerProvider provider = options.JsonLogging ? new FactoryLoggerProvider(category => new JsonConsoleLogger(category)) : new FactoryLoggerProvider(category => new SimpleConsoleLogger(category)); builder.AddProvider(provider); return(builder); }
private static FunctionsFrameworkOptions BindOptions(IConfigurationSource source) { var configuration = new ConfigurationBuilder().Add(source).Build(); return(FunctionsFrameworkOptions.FromConfiguration(configuration)); }
private static FunctionsFrameworkOptions BindOptions(params string[] args) { var configuration = new ConfigurationBuilder().AddFunctionsCommandLine(args).Build(); return(FunctionsFrameworkOptions.FromConfiguration(configuration)); }
/// <summary> /// Configures Kestrel to listen to the port and address specified in the Functions Framework configuration. /// </summary> /// <param name="builder">The web host builder to configure.</param> /// <returns>The original builder, for method chaining.</returns> public static IWebHostBuilder ConfigureKestrelForFunctionsFramework(this IWebHostBuilder builder) => builder.ConfigureKestrel((context, serverOptions) => { var options = FunctionsFrameworkOptions.FromConfiguration(context.Configuration); serverOptions.Listen(options.GetIPAddress(), options.Port); });