add logging

This commit is contained in:
Luke Pulverenti 2016-06-30 19:17:49 -04:00
parent edfd04129e
commit 106087b685
9 changed files with 18 additions and 36 deletions

View File

@ -123,6 +123,7 @@ namespace MediaBrowser.Common.Implementations.Configuration
/// </summary> /// </summary>
public void SaveConfiguration() public void SaveConfiguration()
{ {
Logger.Info("Saving system configuration");
var path = CommonApplicationPaths.SystemConfigurationFilePath; var path = CommonApplicationPaths.SystemConfigurationFilePath;
Directory.CreateDirectory(Path.GetDirectoryName(path)); Directory.CreateDirectory(Path.GetDirectoryName(path));

View File

@ -296,6 +296,8 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
private async Task<HttpResponseInfo> GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url) private async Task<HttpResponseInfo> GetCachedResponse(string responseCachePath, TimeSpan cacheLength, string url)
{ {
_logger.Info("Checking for cache file {0}", responseCachePath);
try try
{ {
if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow) if (_fileSystem.GetLastWriteTimeUtc(responseCachePath).Add(cacheLength) > DateTime.UtcNow)

View File

@ -68,7 +68,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
private Stream OpenFile(string path) private Stream OpenFile(string path)
{ {
_logger.Debug("Deserializing file {0}", path); _logger.Info("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);
} }

View File

@ -80,6 +80,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
/// <param name="file">The file.</param> /// <param name="file">The file.</param>
public void SerializeToFile(object obj, string file) public void SerializeToFile(object obj, string file)
{ {
_logger.Info("Serializing to file {0}", file);
using (var stream = new FileStream(file, FileMode.Create)) using (var stream = new FileStream(file, FileMode.Create))
{ {
SerializeToStream(obj, stream); SerializeToStream(obj, stream);
@ -94,7 +95,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); _logger.Info("Deserializing file {0}", file);
using (var stream = _fileSystem.OpenRead(file)) using (var stream = _fileSystem.OpenRead(file))
{ {
return DeserializeFromStream(type, stream); return DeserializeFromStream(type, stream);

View File

@ -193,6 +193,7 @@ namespace MediaBrowser.Common.Implementations.Updates
/// <returns>Task{List{PackageInfo}}.</returns> /// <returns>Task{List{PackageInfo}}.</returns>
public async Task<IEnumerable<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) public async Task<IEnumerable<PackageInfo>> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken)
{ {
_logger.Info("Opening {0}", PackageCachePath);
try try
{ {
using (var stream = _fileSystem.OpenRead(PackageCachePath)) using (var stream = _fileSystem.OpenRead(PackageCachePath))

View File

@ -12,6 +12,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using CommonIO; using CommonIO;
using MediaBrowser.Model.Logging;
namespace MediaBrowser.Server.Implementations.Localization namespace MediaBrowser.Server.Implementations.Localization
{ {
@ -35,6 +36,7 @@ namespace MediaBrowser.Server.Implementations.Localization
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IJsonSerializer _jsonSerializer; private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LocalizationManager" /> class. /// Initializes a new instance of the <see cref="LocalizationManager" /> class.
@ -42,11 +44,12 @@ namespace MediaBrowser.Server.Implementations.Localization
/// <param name="configurationManager">The configuration manager.</param> /// <param name="configurationManager">The configuration manager.</param>
/// <param name="fileSystem">The file system.</param> /// <param name="fileSystem">The file system.</param>
/// <param name="jsonSerializer">The json serializer.</param> /// <param name="jsonSerializer">The json serializer.</param>
public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer) public LocalizationManager(IServerConfigurationManager configurationManager, IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger)
{ {
_configurationManager = configurationManager; _configurationManager = configurationManager;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_jsonSerializer = jsonSerializer; _jsonSerializer = jsonSerializer;
_logger = logger;
ExtractAll(); ExtractAll();
} }
@ -75,7 +78,10 @@ namespace MediaBrowser.Server.Implementations.Localization
{ {
using (var stream = type.Assembly.GetManifestResourceStream(resource)) using (var stream = type.Assembly.GetManifestResourceStream(resource))
{ {
using (var fs = _fileSystem.GetFileStream(Path.Combine(localizationPath, filename), FileMode.Create, FileAccess.Write, FileShare.Read)) var target = Path.Combine(localizationPath, filename);
_logger.Info("Extracting ratings to {0}", target);
using (var fs = _fileSystem.GetFileStream(target, FileMode.Create, FileAccess.Write, FileShare.Read))
{ {
stream.CopyTo(fs); stream.CopyTo(fs);
} }

View File

@ -3862,7 +3862,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult) ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
: CommandBehavior.SequentialAccess; : CommandBehavior.SequentialAccess;
Logger.Debug("GetItemValues: " + cmd.CommandText); //Logger.Debug("GetItemValues: " + cmd.CommandText);
using (var reader = cmd.ExecuteReader(commandBehavior)) using (var reader = cmd.ExecuteReader(commandBehavior))
{ {

View File

@ -1929,34 +1929,5 @@ namespace MediaBrowser.Server.Mono.Security {
password_max_length = value; password_max_length = value;
} }
} }
// static methods
static private byte[] LoadFile (string filename)
{
byte[] data = null;
using (FileStream fs = File.OpenRead (filename)) {
data = new byte [fs.Length];
fs.Read (data, 0, data.Length);
fs.Close ();
}
return data;
}
static public PKCS12 LoadFromFile (string filename)
{
if (filename == null)
throw new ArgumentNullException ("filename");
return new PKCS12 (LoadFile (filename));
}
static public PKCS12 LoadFromFile (string filename, string password)
{
if (filename == null)
throw new ArgumentNullException ("filename");
return new PKCS12 (LoadFile (filename), password);
}
} }
} }

View File

@ -418,7 +418,7 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance(ServerConfigurationManager); RegisterSingleInstance(ServerConfigurationManager);
LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer); LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LogManager.GetLogger("LocalizationManager"));
RegisterSingleInstance(LocalizationManager); RegisterSingleInstance(LocalizationManager);
RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer()); RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
@ -489,7 +489,7 @@ namespace MediaBrowser.Server.Startup.Common
var encryptionManager = new EncryptionManager(); var encryptionManager = new EncryptionManager();
RegisterSingleInstance<IEncryptionManager>(encryptionManager); RegisterSingleInstance<IEncryptionManager>(encryptionManager);
ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager); ConnectManager = new ConnectManager(LogManager.GetLogger("ConnectManager"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager, SecurityManager, FileSystemManager);
RegisterSingleInstance(ConnectManager); RegisterSingleInstance(ConnectManager);
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager); DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, LogManager.GetLogger("DeviceManager"), FileSystemManager), UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager);