Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings #6816

Merged
merged 1 commit into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 1 addition & 18 deletions Emby.Dlna/DlnaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public DeviceProfile GetDefaultProfile()

if (profile == null)
{
LogUnmatchedProfile(deviceInfo);
_logger.LogInformation("No matching device profile found. The default will need to be used. \n{@Profile}", deviceInfo);
}
else
{
Expand All @@ -122,23 +122,6 @@ public DeviceProfile GetDefaultProfile()
return profile;
}

private void LogUnmatchedProfile(DeviceIdentification profile)
{
var builder = new StringBuilder();

builder.AppendLine("No matching device profile found. The default will need to be used.");
builder.Append("FriendlyName: ").AppendLine(profile.FriendlyName);
builder.Append("Manufacturer: ").AppendLine(profile.Manufacturer);
builder.Append("ManufacturerUrl: ").AppendLine(profile.ManufacturerUrl);
builder.Append("ModelDescription: ").AppendLine(profile.ModelDescription);
builder.Append("ModelName: ").AppendLine(profile.ModelName);
builder.Append("ModelNumber: ").AppendLine(profile.ModelNumber);
builder.Append("ModelUrl: ").AppendLine(profile.ModelUrl);
builder.Append("SerialNumber: ").AppendLine(profile.SerialNumber);

_logger.LogInformation(builder.ToString());
}

/// <summary>
/// Attempts to match a device with a profile.
/// Rules:
Expand Down
7 changes: 1 addition & 6 deletions Emby.Dlna/Main/DlnaEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,6 @@ private void StartSsdpHandler()
}
}

private void LogMessage(string msg)
{
_logger.LogDebug(msg);
}

private void StartDeviceDiscovery(ISsdpCommunicationsServer communicationsServer)
{
try
Expand Down Expand Up @@ -272,7 +267,7 @@ public void StartDevicePublisher(Configuration.DlnaOptions options)
Environment.OSVersion.VersionString,
_config.GetDlnaConfiguration().SendOnlyMatchedHost)
{
LogFunction = LogMessage,
LogFunction = (msg) => _logger.LogDebug("{Msg}", msg),
SupportPnpRootDevice = false
};

Expand Down
7 changes: 2 additions & 5 deletions Emby.Server.Implementations/Dto/DtoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,11 @@ public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user =
var dto = GetBaseItemDtoInternal(item, options, user, owner);
if (item is LiveTvChannel tvChannel)
{
var list = new List<(BaseItemDto, LiveTvChannel)>(1) { (dto, tvChannel) };
LivetvManager.AddChannelInfo(list, options, user);
LivetvManager.AddChannelInfo(new[] { (dto, tvChannel) }, options, user);
}
else if (item is LiveTvProgram)
{
var list = new List<(BaseItem, BaseItemDto)>(1) { (item, dto) };
var task = LivetvManager.AddInfoToProgramDto(list, options.Fields, user);
Task.WaitAll(task);
LivetvManager.AddInfoToProgramDto(new[] { (item, dto) }, options.Fields, user).GetAwaiter().GetResult();
}

if (item is IItemByName itemByName
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/IO/LibraryMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void StartWatchingPath(string path)
if (_fileSystemWatchers.TryAdd(path, newWatcher))
{
newWatcher.EnableRaisingEvents = true;
_logger.LogInformation("Watching directory " + path);
_logger.LogInformation("Watching directory {Path}", path);
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions Emby.Server.Implementations/Library/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ public void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bo
{
try
{
var task = BaseItem.ChannelManager.DeleteItem(item);
Task.WaitAll(task);
BaseItem.ChannelManager.DeleteItem(item).GetAwaiter().GetResult();
}
catch (ArgumentException)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private bool IsMusicAlbum(ItemResolveArgs args)
{
if (parser.IsMultiPart(path))
{
logger.LogDebug("Found multi-disc folder: " + path);
logger.LogDebug("Found multi-disc folder: {Path}", path);
Interlocked.Increment(ref discSubfolderCount);
}
else
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ public Task<MediaSourceInfo> GetChannelStream(string channelId, string streamId,

public async Task<ILiveStream> GetChannelStreamWithDirectStreamProvider(string channelId, string streamId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken)
{
_logger.LogInformation("Streaming Channel " + channelId);
_logger.LogInformation("Streaming Channel {Id}", channelId);

var result = string.IsNullOrEmpty(streamId) ?
null :
Expand Down
5 changes: 2 additions & 3 deletions Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ private async Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile,
ErrorDialog = false
};

var commandLineLogMessage = processStartInfo.FileName + " " + processStartInfo.Arguments;
_logger.LogInformation(commandLineLogMessage);
_logger.LogInformation("{Filename} {Arguments}", processStartInfo.FileName, processStartInfo.Arguments);

var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "record-transcode-" + Guid.NewGuid() + ".txt");
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
Expand All @@ -97,7 +96,7 @@ private async Task RecordFromFile(MediaSourceInfo mediaSource, string inputFile,
_logFileStream = new FileStream(logFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);

await JsonSerializer.SerializeAsync(_logFileStream, mediaSource, _jsonOptions, cancellationToken).ConfigureAwait(false);
await _logFileStream.WriteAsync(Encoding.UTF8.GetBytes(Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine), cancellationToken).ConfigureAwait(false);
await _logFileStream.WriteAsync(Encoding.UTF8.GetBytes(Environment.NewLine + Environment.NewLine + processStartInfo.FileName + " " + processStartInfo.Arguments + Environment.NewLine + Environment.NewLine), cancellationToken).ConfigureAwait(false);

_process = new Process
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ protected virtual void Dispose(bool dispose)
{
try
{
_logger.LogInformation(Name + ": Cancelling");
_logger.LogInformation("{Name}: Cancelling", Name);
token.Cancel();
}
catch (Exception ex)
Expand All @@ -652,16 +652,16 @@ protected virtual void Dispose(bool dispose)
{
try
{
_logger.LogInformation(Name + ": Waiting on Task");
_logger.LogInformation("{Name}: Waiting on Task", Name);
var exited = task.Wait(2000);

if (exited)
{
_logger.LogInformation(Name + ": Task exited");
_logger.LogInformation("{Name}: Task exited", Name);
}
else
{
_logger.LogInformation(Name + ": Timed out waiting for task to stop");
_logger.LogInformation("{Name}: Timed out waiting for task to stop", Name);
}
}
catch (Exception ex)
Expand All @@ -674,7 +674,7 @@ protected virtual void Dispose(bool dispose)
{
try
{
_logger.LogDebug(Name + ": Disposing CancellationToken");
_logger.LogDebug("{Name}: Disposing CancellationToken", Name);
token.Dispose();
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Updates/InstallationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ private async Task<bool> InstallPackageInternal(InstallationInfo package, Cancel
?? _pluginManager.Plugins.FirstOrDefault(p => p.Name.Equals(package.Name, StringComparison.OrdinalIgnoreCase) && p.Version.Equals(package.Version));

await PerformPackageInstallation(package, plugin?.Manifest.Status ?? PluginStatus.Active, cancellationToken).ConfigureAwait(false);
_logger.LogInformation(plugin == null ? "New plugin installed: {PluginName} {PluginVersion}" : "Plugin updated: {PluginName} {PluginVersion}", package.Name, package.Version);
_logger.LogInformation("Plugin {Action}: {PluginName} {PluginVersion}", plugin == null ? "installed" : "updated", package.Name, package.Version);

return plugin != null;
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Api/Controllers/DynamicHlsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ private string GetCommandLineArguments(string outputPath, StreamState state, boo
}
else
{
_logger.LogError("Invalid HLS segment container: " + segmentFormat);
_logger.LogError("Invalid HLS segment container: {SegmentFormat}", segmentFormat);
}

var maxMuxingQueueSize = _encodingOptions.MaxMuxingQueueSize > 128
Expand Down
6 changes: 3 additions & 3 deletions Jellyfin.Api/Helpers/TranscodingJobHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ private void DeleteHlsPartialStreamFiles(string outputFilePath)
state,
cancellationTokenSource);

var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
_logger.LogInformation(commandLineLogMessage);
_logger.LogInformation("{Filename} {Arguments}", process.StartInfo.FileName, process.StartInfo.Arguments);

var logFilePrefix = "FFmpeg.Transcode-";
if (state.VideoRequest != null
Expand All @@ -562,8 +561,9 @@ private void DeleteHlsPartialStreamFiles(string outputFilePath)
// FFmpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, FileOptions.Asynchronous);

var commandLineLogMessage = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(request.Path + Environment.NewLine + Environment.NewLine + JsonSerializer.Serialize(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
await logStream.WriteAsync(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length, cancellationTokenSource.Token).ConfigureAwait(false);
await logStream.WriteAsync(commandLineLogMessageBytes, cancellationTokenSource.Token).ConfigureAwait(false);

process.Exited += (sender, args) => OnFfMpegProcessExited(process, transcodingJob, state);

Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Api/Models/PlaybackDtos/TranscodingThrottler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private bool IsThrottleAllowed(TranscodingJobDto job, int thresholdSeconds)
}
}

_logger.LogDebug("No throttle data for " + path);
_logger.LogDebug("No throttle data for {Path}", path);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions MediaBrowser.Controller/Entities/Folder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ private async Task ValidateChildrenInternal2(IProgress<double> progress, bool re
{
if (item.IsFileProtocol)
{
Logger.LogDebug("Removed item: " + item.Path);
Logger.LogDebug("Removed item: {Path}", item.Path);

item.SetParent(null);
LibraryManager.DeleteItem(item, new DeleteOptions { DeleteFileLocation = false }, this, false);
Expand Down Expand Up @@ -807,7 +807,7 @@ private bool RequiresPostFiltering(InternalItemsQuery query)
{
if (this is not ICollectionFolder)
{
Logger.LogDebug("Query requires post-filtering due to LinkedChildren. Type: " + GetType().Name);
Logger.LogDebug("{Type}: Query requires post-filtering due to LinkedChildren.", GetType().Name);
return true;
}
}
Expand Down
26 changes: 0 additions & 26 deletions MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,6 @@ public interface IMediaEncoder : ITranscoderSupport
/// <returns>Location of video image.</returns>
Task<string> ExtractVideoImage(string inputFile, string container, MediaSourceInfo mediaSource, MediaStream imageStream, int? imageStreamIndex, string outputExtension, CancellationToken cancellationToken);

/// <summary>
/// Extracts the video images on interval.
/// </summary>
/// <param name="inputFile">Input file.</param>
/// <param name="container">Video container type.</param>
/// <param name="videoStream">Media stream information.</param>
/// <param name="mediaSource">Media source information.</param>
/// <param name="threedFormat">Video 3D format.</param>
/// <param name="interval">Time interval.</param>
/// <param name="targetDirectory">Directory to write images.</param>
/// <param name="filenamePrefix">Filename prefix to use.</param>
/// <param name="maxWidth">Maximum width of image.</param>
/// <param name="cancellationToken">CancellationToken to use for operation.</param>
/// <returns>A task.</returns>
Task ExtractVideoImagesOnInterval(
string inputFile,
string container,
MediaStream videoStream,
MediaSourceInfo mediaSource,
Video3DFormat? threedFormat,
TimeSpan interval,
string targetDirectory,
string filenamePrefix,
int? maxWidth,
CancellationToken cancellationToken);

/// <summary>
/// Gets the media info.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected virtual void FetchDataFromXmlNode(XmlReader reader, MetadataResult<T>
}
else
{
Logger.LogWarning("Invalid Added value found: " + val);
Logger.LogWarning("Invalid Added value found: {Value}", val);
}
}

Expand Down
7 changes: 3 additions & 4 deletions MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ await ExtractAttachment(inputFile, mediaSource, mediaAttachment.Index, outputPat

if (failed)
{
var msg = $"ffmpeg attachment extraction failed for {inputPath} to {outputPath}";
_logger.LogError("ffmpeg attachment extraction failed for {InputPath} to {OutputPath}", inputPath, outputPath);

_logger.LogError(msg);

throw new InvalidOperationException(msg);
throw new InvalidOperationException(
string.Format(CultureInfo.InvariantCulture, "ffmpeg attachment extraction failed for {0} to {1}", inputPath, outputPath));
}
else
{
Expand Down