mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
handle year in name when searching
This commit is contained in:
65
MediaBrowser.ServerApplication/Logging/LogForm.Designer.cs
generated
Normal file
65
MediaBrowser.ServerApplication/Logging/LogForm.Designer.cs
generated
Normal file
@@ -0,0 +1,65 @@
|
||||
namespace MediaBrowser.ServerApplication.Logging
|
||||
{
|
||||
partial class LogForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LogForm));
|
||||
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listBox1.Font = new System.Drawing.Font("Consolas", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listBox1.FormattingEnabled = true;
|
||||
this.listBox1.ItemHeight = 18;
|
||||
this.listBox1.Location = new System.Drawing.Point(0, 0);
|
||||
this.listBox1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.listBox1.Name = "listBox1";
|
||||
this.listBox1.Size = new System.Drawing.Size(984, 561);
|
||||
this.listBox1.TabIndex = 0;
|
||||
//
|
||||
// LogForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(984, 561);
|
||||
this.Controls.Add(this.listBox1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "LogForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Media Browser Log";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ListBox listBox1;
|
||||
}
|
||||
}
|
||||
88
MediaBrowser.ServerApplication/Logging/LogForm.cs
Normal file
88
MediaBrowser.ServerApplication/Logging/LogForm.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using MediaBrowser.Common.Implementations.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using NLog.Targets;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MediaBrowser.ServerApplication.Logging
|
||||
{
|
||||
public partial class LogForm : Form
|
||||
{
|
||||
private readonly TaskScheduler _uiThread;
|
||||
private readonly ILogManager _logManager;
|
||||
|
||||
public LogForm(ILogManager logManager)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logManager = logManager;
|
||||
_uiThread = TaskScheduler.FromCurrentSynchronizationContext();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
|
||||
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
|
||||
|
||||
((NlogManager)_logManager).AddLogTarget(new TraceTarget
|
||||
{
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}",
|
||||
Name = "LogWindowTraceTarget"
|
||||
|
||||
}, LogSeverity.Debug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the message.
|
||||
/// </summary>
|
||||
/// <param name="msg">The MSG.</param>
|
||||
public async void LogMessage(string msg)
|
||||
{
|
||||
await Task.Factory.StartNew(() =>
|
||||
{
|
||||
if (listBox1.Items.Count > 10000)
|
||||
{
|
||||
//I think the quickest and safest thing to do here is just clear it out
|
||||
listBox1.Items.Clear();
|
||||
}
|
||||
|
||||
foreach (var line in msg.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
listBox1.Items.Insert(0, line);
|
||||
}
|
||||
}
|
||||
|
||||
}, 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>
|
||||
/// Shuts down.
|
||||
/// </summary>
|
||||
public async void ShutDown()
|
||||
{
|
||||
await Task.Factory.StartNew(Close, CancellationToken.None, TaskCreationOptions.None, _uiThread);
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
base.OnClosing(e);
|
||||
|
||||
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
|
||||
}
|
||||
}
|
||||
}
|
||||
2473
MediaBrowser.ServerApplication/Logging/LogForm.resx
Normal file
2473
MediaBrowser.ServerApplication/Logging/LogForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
<Window x:Class="MediaBrowser.ServerApplication.Logging.LogWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Media Browser Log" Height="300" Width="968">
|
||||
<Grid>
|
||||
<ListBox x:Name="lbxLogData" Margin="10,10,0,0"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,12 +10,12 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
/// <summary>
|
||||
/// The _window
|
||||
/// </summary>
|
||||
private readonly LogWindow _window;
|
||||
private readonly LogForm _window;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WindowTraceListener" /> class.
|
||||
/// </summary>
|
||||
/// <param name="window">The window.</param>
|
||||
public WindowTraceListener(LogWindow window)
|
||||
public WindowTraceListener(LogForm window)
|
||||
{
|
||||
_window = window;
|
||||
_window.Show();
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.ServerApplication.Logging;
|
||||
using MediaBrowser.ServerApplication.Native;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using MediaBrowser.ServerApplication.Native;
|
||||
|
||||
namespace MediaBrowser.ServerApplication
|
||||
{
|
||||
@@ -47,6 +45,8 @@ namespace MediaBrowser.ServerApplication
|
||||
private readonly IDisplayPreferencesRepository _displayPreferencesManager;
|
||||
private readonly IItemRepository _itemRepository;
|
||||
|
||||
private LogForm _logForm;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MainWindow" /> class.
|
||||
/// </summary>
|
||||
@@ -120,9 +120,9 @@ namespace MediaBrowser.ServerApplication
|
||||
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var logWindow = App.Current.Windows.OfType<LogWindow>().FirstOrDefault();
|
||||
var isLogWindowOpen = _logForm != null;
|
||||
|
||||
if ((logWindow == null && _configurationManager.Configuration.ShowLogWindow) || (logWindow != null && !_configurationManager.Configuration.ShowLogWindow))
|
||||
if ((!isLogWindowOpen && _configurationManager.Configuration.ShowLogWindow) || (isLogWindowOpen && !_configurationManager.Configuration.ShowLogWindow))
|
||||
{
|
||||
_logManager.ReloadLogger(_configurationManager.Configuration.EnableDebugLevelLogging ? LogSeverity.Debug : LogSeverity.Info);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace MediaBrowser.ServerApplication
|
||||
// Add our log window if specified
|
||||
if (_configurationManager.Configuration.ShowLogWindow)
|
||||
{
|
||||
Trace.Listeners.Add(new WindowTraceListener(new LogWindow(_logManager)));
|
||||
Trace.Listeners.Add(new WindowTraceListener(new LogForm(_logManager)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,13 +171,10 @@ namespace MediaBrowser.ServerApplication
|
||||
/// </summary>
|
||||
void CloseLogWindow()
|
||||
{
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
if (_logForm != null)
|
||||
{
|
||||
foreach (var win in Application.Current.Windows.OfType<LogWindow>())
|
||||
{
|
||||
win.Close();
|
||||
}
|
||||
});
|
||||
_logForm.ShutDown();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -170,6 +170,12 @@
|
||||
<Compile Include="FFMpeg\FFMpegDownloadInfo.cs" />
|
||||
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
||||
<Compile Include="IO\FileSystemFactory.cs" />
|
||||
<Compile Include="Logging\LogForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Logging\LogForm.Designer.cs">
|
||||
<DependentUpon>LogForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Native\Assemblies.cs" />
|
||||
<Compile Include="Native\NativeApp.cs" />
|
||||
<Compile Include="IO\NativeFileSystem.cs" />
|
||||
@@ -195,10 +201,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Logging\LogWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -214,9 +216,6 @@
|
||||
<Compile Include="LibraryExplorer.xaml.cs">
|
||||
<DependentUpon>LibraryExplorer.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Logging\LogWindow.xaml.cs">
|
||||
<DependentUpon>LogWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Logging\WindowTraceListener.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
@@ -241,6 +240,9 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Logging\LogForm.resx">
|
||||
<DependentUpon>LogForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
Reference in New Issue
Block a user