mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-23 06:38:50 +00:00
formatting (#1847)
This commit is contained in:
@ -1,26 +1,20 @@
|
||||
// to avoid collision with Task in model.cs
|
||||
global using Async = System.Threading.Tasks;
|
||||
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Linq;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Azure.Functions.Worker.Middleware;
|
||||
global using Async = System.Threading.Tasks;
|
||||
using Microsoft.Azure.Functions.Worker;
|
||||
using Microsoft.Azure.Functions.Worker.Middleware;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Microsoft.OneFuzz.Service;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public class LoggingMiddleware : IFunctionsWorkerMiddleware
|
||||
{
|
||||
public async Async.Task Invoke(FunctionContext context, FunctionExecutionDelegate next)
|
||||
{
|
||||
public class Program {
|
||||
public class LoggingMiddleware : IFunctionsWorkerMiddleware {
|
||||
public async Async.Task Invoke(FunctionContext context, FunctionExecutionDelegate next) {
|
||||
var log = (ILogTracerInternal?)context.InstanceServices.GetService<ILogTracer>();
|
||||
if (log is not null)
|
||||
{
|
||||
if (log is not null) {
|
||||
//TODO
|
||||
//if correlation ID is available in HTTP request
|
||||
//if correlation ID is available in Queue message
|
||||
@ -37,14 +31,11 @@ public class Program
|
||||
}
|
||||
|
||||
|
||||
public static List<ILog> GetLoggers(IServiceConfig config)
|
||||
{
|
||||
public static List<ILog> GetLoggers(IServiceConfig config) {
|
||||
List<ILog> loggers = new List<ILog>();
|
||||
foreach (var dest in config.LogDestinations)
|
||||
{
|
||||
foreach (var dest in config.LogDestinations) {
|
||||
loggers.Add(
|
||||
dest switch
|
||||
{
|
||||
dest switch {
|
||||
LogDestination.AppInsights => new AppInsights(config.ApplicationInsightsInstrumentationKey!),
|
||||
LogDestination.Console => new Console(),
|
||||
_ => throw new Exception($"Unhandled Log Destination type: {dest}"),
|
||||
@ -55,12 +46,10 @@ public class Program
|
||||
}
|
||||
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
public static void Main() {
|
||||
var host = new HostBuilder()
|
||||
.ConfigureFunctionsWorkerDefaults(
|
||||
builder =>
|
||||
{
|
||||
builder => {
|
||||
builder.UseMiddleware<LoggingMiddleware>();
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user