mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
rm FilterLists.Agent services from v1 and its AppInsights logger
This commit is contained in:
parent
7ec3fdfe85
commit
6c140d1fb3
2 changed files with 3 additions and 60 deletions
|
|
@ -1,12 +1,10 @@
|
|||
using AutoMapper;
|
||||
using FilterLists.Data;
|
||||
using FilterLists.Services.FilterList;
|
||||
using FilterLists.Services.GitHub;
|
||||
using FilterLists.Services.Language;
|
||||
using FilterLists.Services.License;
|
||||
using FilterLists.Services.Maintainer;
|
||||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Snapshot;
|
||||
using FilterLists.Services.Software;
|
||||
using FilterLists.Services.Syntax;
|
||||
using FilterLists.Services.Tag;
|
||||
|
|
@ -23,9 +21,9 @@ public static void AddFilterListsApiServices(this IServiceCollection services, I
|
|||
{
|
||||
services.AddSingleton(c => config);
|
||||
services.AddEntityFrameworkMySql()
|
||||
.AddDbContextPool<FilterListsDbContext>(o =>
|
||||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
.AddDbContextPool<FilterListsDbContext>(o =>
|
||||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<FilterListService>();
|
||||
services.TryAddScoped<LanguageService>();
|
||||
services.TryAddScoped<LicenseService>();
|
||||
|
|
@ -37,18 +35,5 @@ public static void AddFilterListsApiServices(this IServiceCollection services, I
|
|||
services.TryAddScoped<RuleService>();
|
||||
services.AddAutoMapper(typeof(Service));
|
||||
}
|
||||
|
||||
public static void AddFilterListsAgentServices(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
services.AddSingleton(c => config);
|
||||
services.AddEntityFrameworkMySql()
|
||||
.AddDbContextPool<FilterListsDbContext>(o =>
|
||||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<GitHubService>();
|
||||
services.TryAddScoped<SnapshotService>();
|
||||
services.TryAddScoped<Logger>();
|
||||
services.AddAutoMapper(typeof(Service));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace FilterLists.Services
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class Logger : IDisposable
|
||||
{
|
||||
private const string AppInsightsKeyConfig = "ApplicationInsights:InstrumentationKey";
|
||||
private readonly TelemetryClient telemetryClient;
|
||||
|
||||
public Logger(IConfiguration config)
|
||||
{
|
||||
TelemetryConfiguration.Active.InstrumentationKey = config[AppInsightsKeyConfig];
|
||||
telemetryClient = new TelemetryClient();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
telemetryClient.Flush();
|
||||
|
||||
//https://docs.microsoft.com/en-us/azure/application-insights/app-insights-api-custom-events-metrics#flushing-data
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
|
||||
public void Log(string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
telemetryClient.TrackTrace(message);
|
||||
}
|
||||
|
||||
public void Log(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
telemetryClient.TrackException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue