Skip to content

Commit fc82886

Browse files
authored
Merge branch 'next' into next
2 parents cdfbec4 + 69a93e9 commit fc82886

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

RetailCoder.VBE/App.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,16 @@ public void Startup()
110110
{
111111
EnsureLogFolderPathExists();
112112
EnsureTempPathExists();
113-
LogRubberduckSart();
114113
LoadConfig();
114+
115+
LogRubberduckStart();
116+
UpdateLoggingLevel();
117+
115118
CheckForLegacyIndenterSettings();
116119
_appMenus.Initialize();
117120
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
118121
_appMenus.Localize();
119122

120-
UpdateLoggingLevel();
121-
122123
if (_config.UserSettings.GeneralSettings.CheckVersion)
123124
{
124125
_checkVersionCommand.Execute(null);
@@ -185,19 +186,19 @@ private void CheckForLegacyIndenterSettings()
185186
}
186187
}
187188

188-
private void LogRubberduckSart()
189+
public void LogRubberduckStart()
189190
{
190191
var version = _version.CurrentVersion;
191192
GlobalDiagnosticsContext.Set("RubberduckVersion", version.ToString());
192193
var headers = new List<string>
193194
{
194-
string.Format("Rubberduck version {0} loading:", version),
195+
string.Format("\r\n\tRubberduck version {0} loading:", version),
195196
string.Format("\tOperating System: {0} {1}", Environment.OSVersion.VersionString, Environment.Is64BitOperatingSystem ? "x64" : "x86"),
196197
string.Format("\tHost Product: {0} {1}", Application.ProductName, Environment.Is64BitProcess ? "x64" : "x86"),
197198
string.Format("\tHost Version: {0}", Application.ProductVersion),
198199
string.Format("\tHost Executable: {0}", Path.GetFileName(Application.ExecutablePath)),
199200
};
200-
Logger.Log(LogLevel.Info, string.Join(Environment.NewLine, headers));
201+
LogLevelHelper.SetDebugInfo(string.Join(Environment.NewLine, headers));
201202
}
202203

203204
private bool _disposed;

RetailCoder.VBE/Common/LogLevelHelper.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ public static class LogLevelHelper
1010
{
1111
private static readonly Lazy<IEnumerable<LogLevel>> _logLevels = new Lazy<IEnumerable<LogLevel>>(GetLogLevels);
1212

13+
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
14+
private static string LogHeader;
15+
private static bool LogHeaderWritten;
16+
1317
public static IEnumerable<LogLevel> LogLevels
1418
{
1519
get
@@ -39,8 +43,24 @@ public static int MaxLogLevel()
3943
return GetLogLevels().Max(lvl => lvl.Ordinal);
4044
}
4145

46+
public static void SetDebugInfo(String value)
47+
{
48+
LogHeader = value;
49+
LogHeaderWritten = false;
50+
}
51+
4252
public static void SetMinimumLogLevel(LogLevel minimumLogLevel)
4353
{
54+
if (LogManager.GlobalThreshold == minimumLogLevel)
55+
{
56+
return;
57+
}
58+
if (LogHeaderWritten == true)
59+
{
60+
Logger.Log(LogLevel.Info, "Minimum log level changing from " +
61+
LogManager.GlobalThreshold.Name +
62+
" to " + minimumLogLevel.Name);
63+
}
4464
var loggingRules = LogManager.Configuration.LoggingRules;
4565
foreach (var loggingRule in loggingRules)
4666
{
@@ -49,6 +69,7 @@ public static void SetMinimumLogLevel(LogLevel minimumLogLevel)
4969
if (minimumLogLevel == LogLevel.Off)
5070
{
5171
LogManager.DisableLogging();
72+
LogManager.GlobalThreshold = minimumLogLevel;
5273
LogManager.ReconfigExistingLoggers();
5374
return;
5475
}
@@ -63,7 +84,13 @@ public static void SetMinimumLogLevel(LogLevel minimumLogLevel)
6384
}
6485
}
6586
}
87+
LogManager.GlobalThreshold = minimumLogLevel;
6688
LogManager.ReconfigExistingLoggers();
89+
if (LogHeaderWritten == false)
90+
{
91+
Logger.Log(minimumLogLevel, LogHeader);
92+
LogHeaderWritten = true;
93+
}
6794
}
6895

6996
private static void ClearLogLevels(LoggingRule loggingRule)

0 commit comments

Comments
 (0)