mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	fixed duplicate logs
This commit is contained in:
		
							parent
							
								
									ffa702295a
								
							
						
					
					
						commit
						1d155fefe7
					
				@ -68,7 +68,7 @@ namespace MediaBrowser.Common.Implementations.Logging
 | 
				
			|||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        /// <param name="target">The target.</param>
 | 
					        /// <param name="target">The target.</param>
 | 
				
			||||||
        /// <param name="level">The level.</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;
 | 
					            var config = LogManager.Configuration;
 | 
				
			||||||
            config.AddTarget(target.Name, target);
 | 
					            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>
 | 
					        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
 | 
				
			||||||
        void LogWindow_Loaded(object sender, RoutedEventArgs e)
 | 
					        void LogWindow_Loaded(object sender, RoutedEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var target = new TraceTarget
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Layout = "${longdate}, ${level}, ${logger}, ${message}"
 | 
					 | 
				
			||||||
            };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
 | 
					            ((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
 | 
				
			||||||
            AddLogTarget(target, "LogWindowTraceTarget");
 | 
					
 | 
				
			||||||
 | 
					            ((NlogManager)_logManager).AddLogTarget(new TraceTarget
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                Layout = "${longdate}, ${level}, ${logger}, ${message}",
 | 
				
			||||||
 | 
					                Name = "LogWindowTraceTarget"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }, LogSeverity.Debug);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
 | 
				
			|||||||
@ -80,7 +80,7 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            DataContext = this;
 | 
					            DataContext = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Instance_ConfigurationUpdated(null, EventArgs.Empty);
 | 
					            UpdateButtons();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            _logManager.LoggerLoaded += LoadLogWindow;
 | 
					            _logManager.LoggerLoaded += LoadLogWindow;
 | 
				
			||||||
            _configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated;
 | 
					            _configurationManager.ConfigurationUpdated += Instance_ConfigurationUpdated;
 | 
				
			||||||
@ -92,6 +92,21 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
        /// <param name="sender">The source of the event.</param>
 | 
					        /// <param name="sender">The source of the event.</param>
 | 
				
			||||||
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 | 
					        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 | 
				
			||||||
        void Instance_ConfigurationUpdated(object sender, EventArgs e)
 | 
					        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(() =>
 | 
					            Dispatcher.InvokeAsync(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -102,13 +117,6 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
                separatorDeveloperTools.Visibility = developerToolsVisibility;
 | 
					                separatorDeveloperTools.Visibility = developerToolsVisibility;
 | 
				
			||||||
                cmdReloadServer.Visibility = developerToolsVisibility;
 | 
					                cmdReloadServer.Visibility = developerToolsVisibility;
 | 
				
			||||||
                cmOpenExplorer.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)
 | 
					        void LoadLogWindow(object sender, EventArgs args)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            CloseLogWindow();
 | 
					            CloseLogWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Dispatcher.InvokeAsync(() =>
 | 
					            Dispatcher.InvokeAsync(() =>
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // Add our log window if specified
 | 
					                // Add our log window if specified
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user