mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
fix saving the log level
This commit is contained in:
parent
5dc39b9b3a
commit
84edd6636d
6 changed files with 69 additions and 8 deletions
|
@ -83,6 +83,7 @@
|
|||
<Compile Include="SettingModels\PushBulletNotificationSettings.cs" />
|
||||
<Compile Include="SettingModels\EmailNotificationSettings.cs" />
|
||||
<Compile Include="SettingModels\PlexSettings.cs" />
|
||||
<Compile Include="SettingModels\LogSettings.cs" />
|
||||
<Compile Include="SettingModels\SonarrSettings.cs" />
|
||||
<Compile Include="SettingModels\SickRageSettings.cs" />
|
||||
<Compile Include="SettingModels\CouchPotatoSettings.cs" />
|
||||
|
|
36
PlexRequests.Core/SettingModels/LogSettings.cs
Normal file
36
PlexRequests.Core/SettingModels/LogSettings.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: SickRageSettings.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using NLog;
|
||||
|
||||
namespace PlexRequests.Core.SettingModels
|
||||
{
|
||||
public class LogSettings : Settings
|
||||
{
|
||||
public int Level { get; set; }
|
||||
}
|
||||
}
|
|
@ -78,6 +78,7 @@ namespace PlexRequests.UI
|
|||
container.Register<ISettingsService<PushbulletNotificationSettings>, SettingsServiceV2<PushbulletNotificationSettings>>();
|
||||
container.Register<ISettingsService<PushoverNotificationSettings>, SettingsServiceV2<PushoverNotificationSettings>>();
|
||||
container.Register<ISettingsService<HeadphonesSettings>, SettingsServiceV2<HeadphonesSettings>>();
|
||||
container.Register<ISettingsService<LogSettings>, SettingsServiceV2<LogSettings>>();
|
||||
|
||||
// Repo's
|
||||
container.Register<IRepository<LogEntity>, GenericRepository<LogEntity>>();
|
||||
|
|
|
@ -68,6 +68,7 @@ namespace PlexRequests.UI.Modules
|
|||
private ISettingsService<PushbulletNotificationSettings> PushbulletService { get; }
|
||||
private ISettingsService<PushoverNotificationSettings> PushoverService { get; }
|
||||
private ISettingsService<HeadphonesSettings> HeadphonesService { get; }
|
||||
private ISettingsService<LogSettings> LogService { get; }
|
||||
private IPlexApi PlexApi { get; }
|
||||
private ISonarrApi SonarrApi { get; }
|
||||
private IPushbulletApi PushbulletApi { get; }
|
||||
|
@ -95,6 +96,7 @@ namespace PlexRequests.UI.Modules
|
|||
IRepository<LogEntity> logsRepo,
|
||||
INotificationService notify,
|
||||
ISettingsService<HeadphonesSettings> headphones,
|
||||
ISettingsService<LogSettings> logs,
|
||||
ICacheProvider cache) : base("admin")
|
||||
{
|
||||
PrService = prService;
|
||||
|
@ -114,6 +116,7 @@ namespace PlexRequests.UI.Modules
|
|||
PushoverApi = pushoverApi;
|
||||
NotificationService = notify;
|
||||
HeadphonesService = headphones;
|
||||
LogService = logs;
|
||||
Cache = cache;
|
||||
|
||||
#if !DEBUG
|
||||
|
@ -637,8 +640,16 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private Response UpdateLogLevels(int level)
|
||||
{
|
||||
var settings = LogService.GetSettings();
|
||||
|
||||
// apply the level
|
||||
var newLevel = LogLevel.FromOrdinal(level);
|
||||
LoggingHelper.ReconfigureLogLevel(newLevel);
|
||||
|
||||
//save the log settings
|
||||
settings.Level = level;
|
||||
LogService.SaveSettings(settings);
|
||||
|
||||
return Response.AsJson(new JsonResponseModel { Result = true, Message = $"The new log level is now {newLevel}"});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
// ************************************************************************/
|
||||
#endregion
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Microsoft.Owin.Hosting;
|
||||
|
||||
|
@ -42,8 +41,6 @@ using PlexRequests.Store.Repository;
|
|||
using System.Diagnostics;
|
||||
|
||||
using FluentScheduler;
|
||||
|
||||
using PlexRequests.Services;
|
||||
using PlexRequests.UI.Jobs;
|
||||
|
||||
namespace PlexRequests.UI
|
||||
|
@ -91,6 +88,7 @@ namespace PlexRequests.UI
|
|||
var cn = s.SetupDb(baseUrl);
|
||||
s.CacheQualityProfiles();
|
||||
ConfigureTargets(cn);
|
||||
SetupLogging();
|
||||
|
||||
if (port == -1)
|
||||
port = GetStartupPort();
|
||||
|
@ -157,6 +155,17 @@ namespace PlexRequests.UI
|
|||
LoggingHelper.ConfigureLogging(connectionString);
|
||||
}
|
||||
|
||||
private static void SetupLogging()
|
||||
{
|
||||
var settingsService = new SettingsServiceV2<LogSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
var logSettings = settingsService.GetSettings();
|
||||
|
||||
if (logSettings != null)
|
||||
{
|
||||
LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level));
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetupSchedulers()
|
||||
{
|
||||
TaskManager.TaskFactory = new PlexTaskFactory();
|
||||
|
|
|
@ -76,11 +76,14 @@
|
|||
url: logUrl,
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
$("#select > option").each(function (level) {
|
||||
if (response[0] == level.value) {
|
||||
$('#' + level.target.id).prop("selected", "selected");
|
||||
if (response && response.length > 0) {
|
||||
$("#selected > option").each(function (level) {
|
||||
var $opt = $(this);
|
||||
if (response[0].ordinal == level) {
|
||||
$opt.prop("selected", "selected");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue