From 4ad96e4ff5756ddb235a061231469b30c1ff984d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 4 Oct 2015 18:04:56 -0400 Subject: [PATCH] update logging levels --- Emby.Drawing/ImageProcessor.cs | 4 +-- .../ScheduledTasks/ScheduledTaskWorker.cs | 8 ++--- .../Probing/ProbeResultNormalizer.cs | 35 +++++++++++++------ .../Subtitles/SubtitleEncoder.cs | 2 +- .../MediaInfo/FFProbeVideoInfo.cs | 2 +- .../MediaInfo/VideoImageProvider.cs | 2 +- .../Channels/ChannelPostScanTask.cs | 2 +- .../HttpServer/LoggerUtils.cs | 2 +- .../HttpServer/Security/AuthService.cs | 2 +- .../Security/AuthorizationContext.cs | 6 +++- .../SocketSharp/WebSocketSharpListener.cs | 2 +- .../Session/SessionManager.cs | 6 ++-- .../ApplicationHost.cs | 4 +-- 13 files changed, 48 insertions(+), 29 deletions(-) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 4eecaaced..afec3d03b 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -774,11 +774,11 @@ namespace Emby.Drawing try { - _logger.Debug("Creating image collage and saving to {0}", options.OutputPath); + _logger.Info("Creating image collage and saving to {0}", options.OutputPath); _imageEncoder.CreateImageCollage(options); - _logger.Debug("Completed creation of image collage and saved to {0}", options.OutputPath); + _logger.Info("Completed creation of image collage and saved to {0}", options.OutputPath); } finally { diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index f2b235bd9..52612c4c1 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -626,7 +626,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { try { - Logger.Debug(Name + ": Cancelling"); + Logger.Info(Name + ": Cancelling"); token.Cancel(); } catch (Exception ex) @@ -639,16 +639,16 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks { try { - Logger.Debug(Name + ": Waiting on Task"); + Logger.Info(Name + ": Waiting on Task"); var exited = Task.WaitAll(new[] { task }, 2000); if (exited) { - Logger.Debug(Name + ": Task exited"); + Logger.Info(Name + ": Task exited"); } else { - Logger.Debug(Name + ": Timed out waiting for task to stop"); + Logger.Info(Name + ": Timed out waiting for task to stop"); } } catch (Exception ex) diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index ca760e130..25a8e4876 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -149,7 +149,11 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(streamInfo.sample_rate)) { - stream.SampleRate = int.Parse(streamInfo.sample_rate, _usCulture); + int value; + if (int.TryParse(streamInfo.sample_rate, NumberStyles.Any, _usCulture, out value)) + { + stream.SampleRate = value; + } } stream.ChannelLayout = ParseChannelLayout(streamInfo.channel_layout); @@ -190,12 +194,21 @@ namespace MediaBrowser.MediaEncoding.Probing if (!string.IsNullOrEmpty(streamInfo.bit_rate)) { - bitrate = int.Parse(streamInfo.bit_rate, _usCulture); + int value; + if (int.TryParse(streamInfo.bit_rate, NumberStyles.Any, _usCulture, out value)) + { + bitrate = value; + } } - else if (formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video) + + if (bitrate == 0 && formatInfo != null && !string.IsNullOrEmpty(formatInfo.bit_rate) && stream.Type == MediaStreamType.Video) { // If the stream info doesn't have a bitrate get the value from the media format info - bitrate = int.Parse(formatInfo.bit_rate, _usCulture); + int value; + if (int.TryParse(formatInfo.bit_rate, NumberStyles.Any, _usCulture, out value)) + { + bitrate = value; + } } if (bitrate > 0) @@ -518,23 +531,23 @@ namespace MediaBrowser.MediaEncoding.Probing // These support mulitple values, but for now we only store the first. var mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id")); - if(mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID")); + if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMARTISTID")); audio.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, mb); - + mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id")); - if(mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID")); + if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ARTISTID")); audio.SetProviderId(MetadataProviders.MusicBrainzArtist, mb); mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id")); - if(mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID")); + if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_ALBUMID")); audio.SetProviderId(MetadataProviders.MusicBrainzAlbum, mb); - + mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id")); - if(mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID")); + if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASEGROUPID")); audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, mb); mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id")); - if(mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID")); + if (mb == null) mb = GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MUSICBRAINZ_RELEASETRACKID")); audio.SetProviderId(MetadataProviders.MusicBrainzTrack, mb); } diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 998937d60..aa8efbde2 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -411,7 +411,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles } }; - _logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); + _logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments); var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-convert-" + Guid.NewGuid() + ".txt"); _fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 7d7d37c83..d2aeead5c 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -734,7 +734,7 @@ namespace MediaBrowser.Providers.MediaInfo return minSizeVobs.Count == 0 ? vobs.Select(i => i.FullName) : minSizeVobs.Select(i => i.FullName); } - _logger.Debug("Could not determine vob file list for {0} using DvdLib. Will scan using file sizes.", video.Path); + _logger.Info("Could not determine vob file list for {0} using DvdLib. Will scan using file sizes.", video.Path); } var files = allVobs diff --git a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs index 991f47f80..6b035ed81 100644 --- a/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/VideoImageProvider.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.Providers.MediaInfo // Can't extract if we didn't find a video stream in the file if (!video.DefaultVideoStreamIndex.HasValue) { - _logger.Debug("Skipping image extraction due to missing DefaultVideoStreamIndex for {0}.", video.Path ?? string.Empty); + _logger.Info("Skipping image extraction due to missing DefaultVideoStreamIndex for {0}.", video.Path ?? string.Empty); return Task.FromResult(new DynamicImageResponse { HasImage = false }); } diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelPostScanTask.cs b/MediaBrowser.Server.Implementations/Channels/ChannelPostScanTask.cs index 976fa5615..0321af66b 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelPostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelPostScanTask.cs @@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Channels private async Task CleanChannel(Guid id, CancellationToken cancellationToken) { - _logger.Debug("Cleaning channel {0} from database", id); + _logger.Info("Cleaning channel {0} from database", id); // Delete all channel items var allIds = _libraryManager.GetItemIds(new InternalItemsQuery diff --git a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs index 5558c24d7..f038591aa 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/LoggerUtils.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer var msg = "HTTP Response " + statusCode + " to " + endPoint + responseTime; - logger.LogMultiline(msg, LogSeverity.Debug, log); + logger.LogMultiline(msg, LogSeverity.Info, log); } } } diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index b4da40702..f6b14fcab 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -220,7 +220,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security { if (string.IsNullOrWhiteSpace(token)) { - throw new SecurityException("Access token is invalid or expired."); + throw new SecurityException("Access token is required."); } var info = GetTokenInfo(request); diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index ae5ce796e..509a00ff9 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -62,8 +62,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security auth.TryGetValue("Version", out version); } - var token = httpReq.Headers["X-MediaBrowser-Token"]; + var token = httpReq.Headers["X-Emby-Token"]; + if (string.IsNullOrWhiteSpace(token)) + { + token = httpReq.Headers["X-MediaBrowser-Token"]; + } if (string.IsNullOrWhiteSpace(token)) { token = httpReq.QueryString["api_key"]; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index fdb27d40d..f8178c115 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -191,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp var type = request.IsWebSocketRequest ? "Web Socket" : "HTTP " + request.HttpMethod; - logger.LogMultiline(type + " " + request.Url, LogSeverity.Debug, log); + logger.LogMultiline(type + " " + request.Url, LogSeverity.Info, log); } private void HandleError(Exception ex, HttpListenerContext context) diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index d164874dc..8d3273421 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1324,7 +1324,7 @@ namespace MediaBrowser.Server.Implementations.Session if (existing.Items.Length > 0) { var token = existing.Items[0].AccessToken; - _logger.Debug("Reissuing access token: " + token); + _logger.Info("Reissuing access token: " + token); return token; } @@ -1340,7 +1340,7 @@ namespace MediaBrowser.Server.Implementations.Session AccessToken = Guid.NewGuid().ToString("N") }; - _logger.Debug("Creating new access token for user {0}", userId); + _logger.Info("Creating new access token for user {0}", userId); await _authRepo.Create(newToken, CancellationToken.None).ConfigureAwait(false); return newToken.AccessToken; @@ -1353,6 +1353,8 @@ namespace MediaBrowser.Server.Implementations.Session throw new ArgumentNullException("accessToken"); } + _logger.Info("Logging out access token {0}", accessToken); + var existing = _authRepo.Get(new AuthenticationInfoQuery { Limit = 1, diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index f1833f4fc..f24a3541b 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -502,7 +502,7 @@ namespace MediaBrowser.Server.Startup.Common LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager); RegisterSingleInstance(LiveTvManager); - UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, PlaylistManager, CollectionManager, ServerConfigurationManager); + UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, ServerConfigurationManager); RegisterSingleInstance(UserViewManager); var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager, MediaSourceManager); @@ -944,7 +944,7 @@ namespace MediaBrowser.Server.Startup.Common Logger.ErrorException("Error sending server restart notification", ex); } - Logger.Debug("Calling NativeApp.Restart"); + Logger.Info("Calling NativeApp.Restart"); NativeApp.Restart(_startupOptions); }