Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion RetailCoder.VBE/Common/LogLevelHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NLog;
using System.Linq;
using NLog;
using NLog.Config;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -28,6 +29,16 @@ private static IEnumerable<LogLevel> GetLogLevels()
return logLevels;
}

public static int MinLogLevel()
{
return GetLogLevels().Min(lvl => lvl.Ordinal);
}

public static int MaxLogLevel()
{
return GetLogLevels().Max(lvl => lvl.Ordinal);
}

public static void SetMinimumLogLevel(LogLevel minimumLogLevel)
{
var loggingRules = LogManager.Configuration.LoggingRules;
Expand Down
26 changes: 24 additions & 2 deletions RetailCoder.VBE/Settings/GeneralSettings.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using NLog;
using System;
using NLog;
using System.Xml.Serialization;
using Rubberduck.Common;

namespace Rubberduck.Settings
{
Expand All @@ -23,7 +25,27 @@ public class GeneralSettings : IGeneralSettings
public bool AutoSaveEnabled { get; set; }
public int AutoSavePeriod { get; set; }
public char Delimiter { get; set; }
public int MinimumLogLevel { get; set; }

private int _logLevel;
public int MinimumLogLevel
{
get { return _logLevel; }
set
{
if (value < LogLevelHelper.MinLogLevel())
{
_logLevel = LogLevelHelper.MinLogLevel();
}
else if (value > LogLevelHelper.MaxLogLevel())
{
_logLevel = LogLevelHelper.MaxLogLevel();
}
else
{
_logLevel = value;
}
}
}

public GeneralSettings()
{
Expand Down