mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
fixed duplicate logs
This commit is contained in:
parent
ffa702295a
commit
1d155fefe7
@ -68,7 +68,7 @@ namespace MediaBrowser.Common.Implementations.Logging
|
||||
/// </summary>
|
||||
/// <param name="target">The target.</param>
|
||||
/// <param name="level">The level.</param>
|
||||
private void AddLogTarget(Target target, LogSeverity level)
|
||||
public void AddLogTarget(Target target, LogSeverity level)
|
||||
{
|
||||
var config = LogManager.Configuration;
|
||||
config.AddTarget(target.Name, target);
|
||||
|
@ -42,13 +42,14 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
/// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
|
||||
void LogWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var target = new TraceTarget
|
||||
{
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
||||
};
|
||||
|
||||
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
|
||||
AddLogTarget(target, "LogWindowTraceTarget");
|
||||
|
||||
((NlogManager)_logManager).AddLogTarget(new TraceTarget
|
||||
{
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}",
|
||||
Name = "LogWindowTraceTarget"
|
||||
|
||||
}, LogSeverity.Debug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -80,7 +80,7 @@ namespace MediaBrowser.ServerApplication
|
||||
{
|
||||
DataContext = this;
|
||||
|
||||
Instance_ConfigurationUpdated(null, EventArgs.Empty);
|
||||
UpdateButtons();
|
||||
|
||||
_logManager.LoggerLoaded += LoadLogWindow;
|
||||
_configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated;
|
||||
@ -92,6 +92,21 @@ namespace MediaBrowser.ServerApplication
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void Instance_ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
UpdateButtons();
|
||||
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var logWindow = App.Instance.Windows.OfType<LogWindow>().FirstOrDefault();
|
||||
|
||||
if ((logWindow == null && _configurationManager.Configuration.ShowLogWindow) || (logWindow != null && !_configurationManager.Configuration.ShowLogWindow))
|
||||
{
|
||||
_logManager.ReloadLogger(_configurationManager.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateButtons()
|
||||
{
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
@ -102,13 +117,6 @@ namespace MediaBrowser.ServerApplication
|
||||
separatorDeveloperTools.Visibility = developerToolsVisibility;
|
||||
cmdReloadServer.Visibility = developerToolsVisibility;
|
||||
cmOpenExplorer.Visibility = developerToolsVisibility;
|
||||
|
||||
var logWindow = App.Instance.Windows.OfType<LogWindow>().FirstOrDefault();
|
||||
|
||||
if ((logWindow == null && _configurationManager.Configuration.ShowLogWindow) || (logWindow != null && !_configurationManager.Configuration.ShowLogWindow))
|
||||
{
|
||||
_logManager.ReloadLogger(_configurationManager.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -120,6 +128,7 @@ namespace MediaBrowser.ServerApplication
|
||||
void LoadLogWindow(object sender, EventArgs args)
|
||||
{
|
||||
CloseLogWindow();
|
||||
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
// Add our log window if specified
|
||||
|
Loading…
Reference in New Issue
Block a user