update logging
This commit is contained in:
parent
636969e7ff
commit
dc5f2dd440
|
@ -199,7 +199,7 @@ namespace MediaBrowser.Common.Implementations
|
||||||
ILogManager logManager,
|
ILogManager logManager,
|
||||||
IFileSystem fileSystem)
|
IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
XmlSerializer = new MediaBrowser.Common.Implementations.Serialization.XmlSerializer (fileSystem);
|
XmlSerializer = new XmlSerializer (fileSystem, logManager.GetLogger("XmlSerializer"));
|
||||||
FailedAssemblies = new List<string>();
|
FailedAssemblies = new List<string>();
|
||||||
|
|
||||||
ApplicationPaths = applicationPaths;
|
ApplicationPaths = applicationPaths;
|
||||||
|
@ -321,7 +321,7 @@ namespace MediaBrowser.Common.Implementations
|
||||||
|
|
||||||
protected virtual IJsonSerializer CreateJsonSerializer()
|
protected virtual IJsonSerializer CreateJsonSerializer()
|
||||||
{
|
{
|
||||||
return new JsonSerializer(FileSystemManager);
|
return new JsonSerializer(FileSystemManager, LogManager.GetLogger("JsonSerializer"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetHttpLimit()
|
private void SetHttpLimit()
|
||||||
|
|
|
@ -121,8 +121,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
public TaskResult LastExecutionResult
|
public TaskResult LastExecutionResult
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
|
||||||
if (_lastExecutionResult == null)
|
|
||||||
{
|
{
|
||||||
var path = GetHistoryFilePath();
|
var path = GetHistoryFilePath();
|
||||||
|
|
||||||
|
@ -132,7 +130,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return JsonSerializer.DeserializeFromFile<TaskResult>(path);
|
_lastExecutionResult = JsonSerializer.DeserializeFromFile<TaskResult>(path);
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +146,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return _lastExecutionResult;
|
return _lastExecutionResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Implementations.Serialization
|
namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
{
|
{
|
||||||
|
@ -11,10 +12,12 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
public class JsonSerializer : IJsonSerializer
|
public class JsonSerializer : IJsonSerializer
|
||||||
{
|
{
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public JsonSerializer(IFileSystem fileSystem)
|
public JsonSerializer(IFileSystem fileSystem, ILogger logger)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_logger = logger;
|
||||||
Configure();
|
Configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +68,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
|
|
||||||
private Stream OpenFile(string path)
|
private Stream OpenFile(string path)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Deserializing file {0}", path);
|
||||||
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072);
|
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 131072);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Concurrent;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Implementations.Serialization
|
namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
{
|
{
|
||||||
|
@ -12,11 +13,13 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class XmlSerializer : IXmlSerializer
|
public class XmlSerializer : IXmlSerializer
|
||||||
{
|
{
|
||||||
private IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
public XmlSerializer(IFileSystem fileSystem)
|
public XmlSerializer(IFileSystem fileSystem, ILogger logger)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to cache these
|
// Need to cache these
|
||||||
|
@ -91,6 +94,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
public object DeserializeFromFile(Type type, string file)
|
public object DeserializeFromFile(Type type, string file)
|
||||||
{
|
{
|
||||||
|
_logger.Debug("Deserializing file {0}", file);
|
||||||
using (var stream = _fileSystem.OpenRead(file))
|
using (var stream = _fileSystem.OpenRead(file))
|
||||||
{
|
{
|
||||||
return DeserializeFromStream(type, stream);
|
return DeserializeFromStream(type, stream);
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
private List<DeviceInfo> _devices;
|
private Dictionary<string, DeviceInfo> _devices;
|
||||||
|
|
||||||
public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem)
|
public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||||
lock (_syncLock)
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
_json.SerializeToFile(device, path);
|
_json.SerializeToFile(device, path);
|
||||||
_devices = null;
|
_devices[device.Id] = device;
|
||||||
}
|
}
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
@ -95,9 +95,15 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||||
{
|
{
|
||||||
if (_devices == null)
|
if (_devices == null)
|
||||||
{
|
{
|
||||||
_devices = LoadDevices().ToList();
|
_devices = new Dictionary<string, DeviceInfo>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
var devices = LoadDevices().ToList();
|
||||||
|
foreach (var device in devices)
|
||||||
|
{
|
||||||
|
_devices[device.Id] = device;
|
||||||
}
|
}
|
||||||
return _devices.ToList();
|
}
|
||||||
|
return _devices.Values.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user