mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* If the user is on Debug, allow logging DB params to the logger. Implemented the ability to change logger from UI and to keep the DB settings of LogLevel and Port in sync with appsettings. * Exclude a lot more clutter from hitting Sentry * Removed github action * Small cleanup
55 lines
2.2 KiB
C#
55 lines
2.2 KiB
C#
using System;
|
|
using API.Data;
|
|
using API.Helpers;
|
|
using API.Interfaces;
|
|
using API.Interfaces.Services;
|
|
using API.Services;
|
|
using API.Services.Tasks;
|
|
using Kavita.Common;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace API.Extensions
|
|
{
|
|
public static class ApplicationServiceExtensions
|
|
{
|
|
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config, IWebHostEnvironment env)
|
|
{
|
|
services.AddAutoMapper(typeof(AutoMapperProfiles).Assembly);
|
|
services.AddScoped<ITaskScheduler, TaskScheduler>();
|
|
services.AddScoped<IDirectoryService, DirectoryService>();
|
|
services.AddScoped<ITokenService, TokenService>();
|
|
services.AddScoped<ICacheService, CacheService>();
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
services.AddScoped<IScannerService, ScannerService>();
|
|
services.AddScoped<IArchiveService, ArchiveService>();
|
|
services.AddScoped<IMetadataService, MetadataService>();
|
|
services.AddScoped<IBackupService, BackupService>();
|
|
services.AddScoped<ICleanupService, CleanupService>();
|
|
services.AddScoped<IBookService, BookService>();
|
|
|
|
|
|
services.AddDbContext<DataContext>(options =>
|
|
{
|
|
options.UseSqlite(config.GetConnectionString("DefaultConnection"));
|
|
options.EnableSensitiveDataLogging(env.IsDevelopment() || Configuration.GetLogLevel(Program.GetAppSettingFilename()).Equals("Debug"));
|
|
});
|
|
|
|
services.AddLogging(loggingBuilder =>
|
|
{
|
|
var loggingSection = config.GetSection("Logging");
|
|
loggingBuilder.AddFile(loggingSection);
|
|
});
|
|
|
|
return services;
|
|
}
|
|
|
|
public static IServiceCollection AddStartupTask<T>(this IServiceCollection services)
|
|
where T : class, IStartupTask
|
|
=> services.AddTransient<IStartupTask, T>();
|
|
}
|
|
} |