diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-13 23:00:13 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-02-13 23:00:13 -0500 |
| commit | a4b40ad9d90a40cd5e35bb7b9c43ad436e992cd4 (patch) | |
| tree | 84a697bf606b293c3e74d7757b28d3bb40d1d269 /MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs | |
| parent | 58a46171ababb816636a65aa7f76c00de50f598f (diff) | |
handle year in name when searching
Diffstat (limited to 'MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs b/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs deleted file mode 100644 index f26fcb26c..000000000 --- a/MediaBrowser.ServerApplication/Logging/LogWindow.xaml.cs +++ /dev/null @@ -1,123 +0,0 @@ -using MediaBrowser.Common.Implementations.Logging; -using MediaBrowser.Model.Logging; -using NLog; -using NLog.Config; -using NLog.Targets; -using System.ComponentModel; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; - -namespace MediaBrowser.ServerApplication.Logging -{ - /// <summary> - /// Interaction logic for LogWindow.xaml - /// </summary> - public partial class LogWindow : Window - { - /// <summary> - /// The _ui thread - /// </summary> - private readonly TaskScheduler _uiThread; - - private readonly ILogManager _logManager; - - /// <summary> - /// Initializes a new instance of the <see cref="LogWindow" /> class. - /// </summary> - /// <param name="kernel">The kernel.</param> - public LogWindow(ILogManager logManager) - { - InitializeComponent(); - _uiThread = TaskScheduler.FromCurrentSynchronizationContext(); - _logManager = logManager; - - Loaded += LogWindow_Loaded; - } - - /// <summary> - /// Handles the Loaded event of the LogWindow control. - /// </summary> - /// <param name="sender">The source of the event.</param> - /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param> - void LogWindow_Loaded(object sender, RoutedEventArgs e) - { - ((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget"); - - ((NlogManager)_logManager).AddLogTarget(new TraceTarget - { - Layout = "${longdate}, ${level}, ${logger}, ${message}", - Name = "LogWindowTraceTarget" - - }, LogSeverity.Debug); - } - - /// <summary> - /// Raises the <see cref="E:System.Windows.Window.Closing" /> event. - /// </summary> - /// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs" /> that contains the event data.</param> - protected override void OnClosing(CancelEventArgs e) - { - base.OnClosing(e); - - ((NlogManager) _logManager).RemoveTarget("LogWindowTraceTarget"); - } - - /// <summary> - /// Logs the message. - /// </summary> - /// <param name="msg">The MSG.</param> - public async void LogMessage(string msg) - { - await Task.Factory.StartNew(() => - { - if (lbxLogData.Items.Count > 10000) - { - //I think the quickest and safest thing to do here is just clear it out - lbxLogData.Items.Clear(); - } - - lbxLogData.Items.Insert(0, msg.TrimEnd('\n')); - }, CancellationToken.None, TaskCreationOptions.None, _uiThread); - } - - /// <summary> - /// The log layout - /// </summary> - /// <value>The log layout.</value> - public string LogLayout - { - get { return "${longdate}, ${level}, ${logger}, ${message}"; } - } - - /// <summary> - /// Adds the log target. - /// </summary> - /// <param name="target">The target.</param> - /// <param name="name">The name.</param> - private void AddLogTarget(Target target, string name) - { - var config = NLog.LogManager.Configuration; - - target.Name = name; - config.AddTarget(name, target); - - var level = LogLevel.Debug; - - var rule = new LoggingRule("*", level, target); - config.LoggingRules.Add(rule); - - NLog.LogManager.Configuration = config; - } - - /// <summary> - /// Shuts down. - /// </summary> - public async void ShutDown() - { - await Task.Factory.StartNew(Close, CancellationToken.None, TaskCreationOptions.None, _uiThread); - } - - } - -} |
