3.0.5464.40000

This commit is contained in:
Luke Pulverenti 2014-12-17 17:39:17 -05:00
parent 3763f7d912
commit e3484bdcc2
10 changed files with 92 additions and 31 deletions

View File

@ -294,19 +294,20 @@ namespace MediaBrowser.Common.Implementations
public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup) public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup)
{ {
if (isStartup) logger.LogMultiline("Media Browser", LogSeverity.Info, GetBaseExceptionMessage(appPaths));
{
logger.Info("Media Browser Server started");
} }
logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())); protected static StringBuilder GetBaseExceptionMessage(IApplicationPaths appPaths)
{
var builder = new StringBuilder();
logger.Info("Server: {0}", Environment.MachineName); builder.AppendLine(string.Format("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs())));
logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
logger.Info("Processor count: {0}", Environment.ProcessorCount); builder.AppendLine(string.Format("Operating system: {0}", Environment.OSVersion));
logger.Info("64-Bit OS: {0}", Environment.Is64BitOperatingSystem); builder.AppendLine(string.Format("Processor count: {0}", Environment.ProcessorCount));
logger.Info("64-Bit Process: {0}", Environment.Is64BitProcess); builder.AppendLine(string.Format("64-Bit OS: {0}", Environment.Is64BitOperatingSystem));
logger.Info("Program data path: {0}", appPaths.ProgramDataPath); builder.AppendLine(string.Format("64-Bit Process: {0}", Environment.Is64BitProcess));
builder.AppendLine(string.Format("Program data path: {0}", appPaths.ProgramDataPath));
Type type = Type.GetType("Mono.Runtime"); Type type = Type.GetType("Mono.Runtime");
if (type != null) if (type != null)
@ -314,13 +315,13 @@ namespace MediaBrowser.Common.Implementations
MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
if (displayName != null) if (displayName != null)
{ {
logger.Info("Mono: " + displayName.Invoke(null, null)); builder.AppendLine("Mono: " + displayName.Invoke(null, null));
} }
} }
logger.Info("Application Path: {0}", appPaths.ApplicationPath); builder.AppendLine(string.Format("Application Path: {0}", appPaths.ApplicationPath));
logger.Info("*** When reporting issues please include the entire log file. ***".ToUpper()); return builder;
} }
protected virtual IJsonSerializer CreateJsonSerializer() protected virtual IJsonSerializer CreateJsonSerializer()

View File

@ -14,6 +14,8 @@ namespace MediaBrowser.Common.Implementations.Logging
/// </summary> /// </summary>
private readonly NLog.Logger _logger; private readonly NLog.Logger _logger;
private readonly ILogManager _logManager;
/// <summary> /// <summary>
/// The _lock object /// The _lock object
/// </summary> /// </summary>
@ -23,8 +25,10 @@ namespace MediaBrowser.Common.Implementations.Logging
/// Initializes a new instance of the <see cref="NLogger" /> class. /// Initializes a new instance of the <see cref="NLogger" /> class.
/// </summary> /// </summary>
/// <param name="name">The name.</param> /// <param name="name">The name.</param>
public NLogger(string name) /// <param name="logManager">The log manager.</param>
public NLogger(string name, ILogManager logManager)
{ {
_logManager = logManager;
lock (LockObject) lock (LockObject)
{ {
_logger = NLog.LogManager.GetLogger(name); _logger = NLog.LogManager.GetLogger(name);
@ -96,6 +100,13 @@ namespace MediaBrowser.Common.Implementations.Logging
var messageText = LogHelper.GetLogMessage(exception); var messageText = LogHelper.GetLogMessage(exception);
var prefix = _logManager.ExceptionMessagePrefix;
if (!string.IsNullOrWhiteSpace(prefix))
{
messageText.Insert(0, prefix);
}
LogMultiline(message, level, messageText); LogMultiline(message, level, messageText);
} }

View File

@ -34,6 +34,12 @@ namespace MediaBrowser.Common.Implementations.Logging
/// <value>The log file path.</value> /// <value>The log file path.</value>
public string LogFilePath { get; private set; } public string LogFilePath { get; private set; }
/// <summary>
/// Gets or sets the exception message prefix.
/// </summary>
/// <value>The exception message prefix.</value>
public string ExceptionMessagePrefix { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="NlogManager" /> class. /// Initializes a new instance of the <see cref="NlogManager" /> class.
/// </summary> /// </summary>
@ -159,7 +165,7 @@ namespace MediaBrowser.Common.Implementations.Logging
/// <returns>ILogger.</returns> /// <returns>ILogger.</returns>
public ILogger GetLogger(string name) public ILogger GetLogger(string name)
{ {
return new NLogger(name); return new NLogger(name, this);
} }
/// <summary> /// <summary>

View File

@ -13,6 +13,12 @@ namespace MediaBrowser.Model.Logging
/// <value>The log level.</value> /// <value>The log level.</value>
LogSeverity LogSeverity { get; set; } LogSeverity LogSeverity { get; set; }
/// <summary>
/// Gets or sets the exception message prefix.
/// </summary>
/// <value>The exception message prefix.</value>
string ExceptionMessagePrefix { get; set; }
/// <summary> /// <summary>
/// Gets the logger. /// Gets the logger.
/// </summary> /// </summary>

View File

@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sync
throw new InvalidOperationException("Cannot proceed with sync because user no longer exists."); throw new InvalidOperationException("Cannot proceed with sync because user no longer exists.");
} }
var items = GetItemsForSync(job.RequestedItemIds, user) var items = GetItemsForSync(job.RequestedItemIds, user, job.UnwatchedOnly)
.ToList(); .ToList();
var jobItems = _syncRepo.GetJobItems(new SyncJobItemQuery var jobItems = _syncRepo.GetJobItems(new SyncJobItemQuery
@ -171,12 +171,31 @@ namespace MediaBrowser.Server.Implementations.Sync
return _syncRepo.Update(job); return _syncRepo.Update(job);
} }
public IEnumerable<BaseItem> GetItemsForSync(IEnumerable<string> itemIds, User user) public IEnumerable<BaseItem> GetItemsForSync(IEnumerable<string> itemIds, User user, bool unwatchedOnly)
{ {
return itemIds var items = itemIds
.SelectMany(i => GetItemsForSync(i, user)) .SelectMany(i => GetItemsForSync(i, user))
.Where(_syncManager.SupportsSync) .Where(_syncManager.SupportsSync);
.DistinctBy(i => i.Id);
if (unwatchedOnly)
{
// Avoid implicitly captured closure
var currentUser = user;
items = items.Where(i =>
{
var video = i as Video;
if (video != null)
{
return !video.IsPlayed(currentUser);
}
return true;
});
}
return items.DistinctBy(i => i.Id);
} }
private IEnumerable<BaseItem> GetItemsForSync(string id, User user) private IEnumerable<BaseItem> GetItemsForSync(string id, User user)

View File

@ -49,7 +49,7 @@ namespace MediaBrowser.Server.Implementations.Sync
var user = _userManager.GetUserById(request.UserId); var user = _userManager.GetUserById(request.UserId);
var items = processor var items = processor
.GetItemsForSync(request.ItemIds, user) .GetItemsForSync(request.ItemIds, user, request.UnwatchedOnly)
.ToList(); .ToList();
if (items.Any(i => !SupportsSync(i))) if (items.Any(i => !SupportsSync(i)))

View File

@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public bool IsHidden public bool IsHidden
{ {
get { return false; } get { return true; }
} }
public bool IsEnabled public bool IsEnabled

View File

@ -251,6 +251,8 @@ namespace MediaBrowser.Server.Startup.Common
_remotePackageName = remotePackageName; _remotePackageName = remotePackageName;
_supportsNativeWebSocket = supportsNativeWebSocket; _supportsNativeWebSocket = supportsNativeWebSocket;
NativeApp = nativeApp; NativeApp = nativeApp;
SetBaseExceptionMessage();
} }
private Version _version; private Version _version;
@ -307,6 +309,23 @@ namespace MediaBrowser.Server.Startup.Common
get { return NativeApp.SupportsAutoRunAtStartup; } get { return NativeApp.SupportsAutoRunAtStartup; }
} }
private void SetBaseExceptionMessage()
{
var builder = GetBaseExceptionMessage(ApplicationPaths);
// Skip if plugins haven't been loaded yet
//if (Plugins != null)
//{
// var pluginString = string.Join("|", Plugins.Select(i => i.Name + "-" + i.Version.ToString()).ToArray());
// builder.Insert(0, string.Format("Plugins: {0}{1}", pluginString, Environment.NewLine));
//}
builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine));
builder.Insert(0, "*** Error Report ***" + Environment.NewLine);
LogManager.ExceptionMessagePrefix = builder.ToString();
}
/// <summary> /// <summary>
/// Runs the startup tasks. /// Runs the startup tasks.
/// </summary> /// </summary>

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Common.Implementations.Logging;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations; using MediaBrowser.Server.Implementations;
using MediaBrowser.Server.Startup.Common; using MediaBrowser.Server.Startup.Common;

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
[assembly: AssemblyVersion("3.0.*")] //[assembly: AssemblyVersion("3.0.*")]
//[assembly: AssemblyVersion("3.0.5463.3000")] [assembly: AssemblyVersion("3.0.5464.40000")]