ActivityLogEntryPoint.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Jellyfin.Data.Entities;
  8. using MediaBrowser.Common.Plugins;
  9. using MediaBrowser.Common.Updates;
  10. using MediaBrowser.Controller.Authentication;
  11. using MediaBrowser.Controller.Devices;
  12. using MediaBrowser.Controller.Library;
  13. using MediaBrowser.Controller.Plugins;
  14. using MediaBrowser.Controller.Session;
  15. using MediaBrowser.Controller.Subtitles;
  16. using MediaBrowser.Model.Activity;
  17. using MediaBrowser.Model.Dto;
  18. using MediaBrowser.Model.Entities;
  19. using MediaBrowser.Model.Events;
  20. using MediaBrowser.Model.Globalization;
  21. using MediaBrowser.Model.Notifications;
  22. using MediaBrowser.Model.Tasks;
  23. using MediaBrowser.Model.Updates;
  24. using Microsoft.Extensions.Logging;
  25. namespace Emby.Server.Implementations.Activity
  26. {
  27. /// <summary>
  28. /// Entry point for the activity logger.
  29. /// </summary>
  30. public sealed class ActivityLogEntryPoint : IServerEntryPoint
  31. {
  32. private readonly ILogger _logger;
  33. private readonly IInstallationManager _installationManager;
  34. private readonly ISessionManager _sessionManager;
  35. private readonly ITaskManager _taskManager;
  36. private readonly IActivityManager _activityManager;
  37. private readonly ILocalizationManager _localization;
  38. private readonly ISubtitleManager _subManager;
  39. private readonly IUserManager _userManager;
  40. private readonly IDeviceManager _deviceManager;
  41. /// <summary>
  42. /// Initializes a new instance of the <see cref="ActivityLogEntryPoint"/> class.
  43. /// </summary>
  44. /// <param name="logger">The logger.</param>
  45. /// <param name="sessionManager">The session manager.</param>
  46. /// <param name="deviceManager">The device manager.</param>
  47. /// <param name="taskManager">The task manager.</param>
  48. /// <param name="activityManager">The activity manager.</param>
  49. /// <param name="localization">The localization manager.</param>
  50. /// <param name="installationManager">The installation manager.</param>
  51. /// <param name="subManager">The subtitle manager.</param>
  52. /// <param name="userManager">The user manager.</param>
  53. public ActivityLogEntryPoint(
  54. ILogger<ActivityLogEntryPoint> logger,
  55. ISessionManager sessionManager,
  56. IDeviceManager deviceManager,
  57. ITaskManager taskManager,
  58. IActivityManager activityManager,
  59. ILocalizationManager localization,
  60. IInstallationManager installationManager,
  61. ISubtitleManager subManager,
  62. IUserManager userManager)
  63. {
  64. _logger = logger;
  65. _sessionManager = sessionManager;
  66. _deviceManager = deviceManager;
  67. _taskManager = taskManager;
  68. _activityManager = activityManager;
  69. _localization = localization;
  70. _installationManager = installationManager;
  71. _subManager = subManager;
  72. _userManager = userManager;
  73. }
  74. /// <inheritdoc />
  75. public Task RunAsync()
  76. {
  77. _taskManager.TaskCompleted += OnTaskCompleted;
  78. _installationManager.PluginInstalled += OnPluginInstalled;
  79. _installationManager.PluginUninstalled += OnPluginUninstalled;
  80. _installationManager.PluginUpdated += OnPluginUpdated;
  81. _installationManager.PackageInstallationFailed += OnPackageInstallationFailed;
  82. _sessionManager.SessionStarted += OnSessionStarted;
  83. _sessionManager.AuthenticationFailed += OnAuthenticationFailed;
  84. _sessionManager.AuthenticationSucceeded += OnAuthenticationSucceeded;
  85. _sessionManager.SessionEnded += OnSessionEnded;
  86. _sessionManager.PlaybackStart += OnPlaybackStart;
  87. _sessionManager.PlaybackStopped += OnPlaybackStopped;
  88. _subManager.SubtitleDownloadFailure += OnSubtitleDownloadFailure;
  89. _userManager.OnUserCreated += OnUserCreated;
  90. _userManager.OnUserPasswordChanged += OnUserPasswordChanged;
  91. _userManager.OnUserDeleted += OnUserDeleted;
  92. _userManager.OnUserLockedOut += OnUserLockedOut;
  93. _deviceManager.CameraImageUploaded += OnCameraImageUploaded;
  94. return Task.CompletedTask;
  95. }
  96. private async void OnCameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)
  97. {
  98. await CreateLogEntry(new ActivityLog(
  99. string.Format(
  100. CultureInfo.InvariantCulture,
  101. _localization.GetLocalizedString("CameraImageUploadedFrom"),
  102. e.Argument.Device.Name),
  103. NotificationType.CameraImageUploaded.ToString(),
  104. Guid.Empty,
  105. DateTime.UtcNow,
  106. LogLevel.Trace))
  107. .ConfigureAwait(false);
  108. }
  109. private async void OnUserLockedOut(object sender, GenericEventArgs<User> e)
  110. {
  111. await CreateLogEntry(new ActivityLog(
  112. string.Format(
  113. CultureInfo.InvariantCulture,
  114. _localization.GetLocalizedString("UserLockedOutWithName"),
  115. e.Argument.Username),
  116. NotificationType.UserLockedOut.ToString(),
  117. e.Argument.Id,
  118. DateTime.UtcNow,
  119. LogLevel.Trace))
  120. .ConfigureAwait(false);
  121. }
  122. private async void OnSubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
  123. {
  124. await CreateLogEntry(new ActivityLog(
  125. string.Format(
  126. CultureInfo.InvariantCulture,
  127. _localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"),
  128. e.Provider,
  129. Emby.Notifications.NotificationEntryPoint.GetItemName(e.Item)),
  130. "SubtitleDownloadFailure",
  131. Guid.Empty,
  132. DateTime.UtcNow,
  133. LogLevel.Trace)
  134. {
  135. ItemId = e.Item.Id.ToString("N", CultureInfo.InvariantCulture),
  136. ShortOverview = e.Exception.Message
  137. }).ConfigureAwait(false);
  138. }
  139. private async void OnPlaybackStopped(object sender, PlaybackStopEventArgs e)
  140. {
  141. var item = e.MediaInfo;
  142. if (item == null)
  143. {
  144. _logger.LogWarning("PlaybackStopped reported with null media info.");
  145. return;
  146. }
  147. if (e.Item != null && e.Item.IsThemeMedia)
  148. {
  149. // Don't report theme song or local trailer playback
  150. return;
  151. }
  152. if (e.Users.Count == 0)
  153. {
  154. return;
  155. }
  156. var user = e.Users[0];
  157. await CreateLogEntry(new ActivityLog(
  158. string.Format(
  159. CultureInfo.InvariantCulture,
  160. _localization.GetLocalizedString("UserStoppedPlayingItemWithValues"),
  161. user.Username,
  162. GetItemName(item),
  163. e.DeviceName),
  164. GetPlaybackStoppedNotificationType(item.MediaType),
  165. user.Id,
  166. DateTime.UtcNow,
  167. LogLevel.Trace))
  168. .ConfigureAwait(false);
  169. }
  170. private async void OnPlaybackStart(object sender, PlaybackProgressEventArgs e)
  171. {
  172. var item = e.MediaInfo;
  173. if (item == null)
  174. {
  175. _logger.LogWarning("PlaybackStart reported with null media info.");
  176. return;
  177. }
  178. if (e.Item != null && e.Item.IsThemeMedia)
  179. {
  180. // Don't report theme song or local trailer playback
  181. return;
  182. }
  183. if (e.Users.Count == 0)
  184. {
  185. return;
  186. }
  187. var user = e.Users.First();
  188. await CreateLogEntry(new ActivityLog(
  189. string.Format(
  190. CultureInfo.InvariantCulture,
  191. _localization.GetLocalizedString("UserStartedPlayingItemWithValues"),
  192. user.Username,
  193. GetItemName(item),
  194. e.DeviceName),
  195. GetPlaybackNotificationType(item.MediaType),
  196. user.Id,
  197. DateTime.UtcNow,
  198. LogLevel.Trace))
  199. .ConfigureAwait(false);
  200. }
  201. private static string GetItemName(BaseItemDto item)
  202. {
  203. var name = item.Name;
  204. if (!string.IsNullOrEmpty(item.SeriesName))
  205. {
  206. name = item.SeriesName + " - " + name;
  207. }
  208. if (item.Artists != null && item.Artists.Count > 0)
  209. {
  210. name = item.Artists[0] + " - " + name;
  211. }
  212. return name;
  213. }
  214. private static string GetPlaybackNotificationType(string mediaType)
  215. {
  216. if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
  217. {
  218. return NotificationType.AudioPlayback.ToString();
  219. }
  220. if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
  221. {
  222. return NotificationType.VideoPlayback.ToString();
  223. }
  224. return null;
  225. }
  226. private static string GetPlaybackStoppedNotificationType(string mediaType)
  227. {
  228. if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
  229. {
  230. return NotificationType.AudioPlaybackStopped.ToString();
  231. }
  232. if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
  233. {
  234. return NotificationType.VideoPlaybackStopped.ToString();
  235. }
  236. return null;
  237. }
  238. private async void OnSessionEnded(object sender, SessionEventArgs e)
  239. {
  240. var session = e.SessionInfo;
  241. if (string.IsNullOrEmpty(session.UserName))
  242. {
  243. return;
  244. }
  245. await CreateLogEntry(new ActivityLog(
  246. string.Format(
  247. CultureInfo.InvariantCulture,
  248. _localization.GetLocalizedString("UserOfflineFromDevice"),
  249. session.UserName,
  250. session.DeviceName),
  251. "SessionEnded",
  252. session.UserId,
  253. DateTime.UtcNow,
  254. LogLevel.Trace)
  255. {
  256. ShortOverview = string.Format(
  257. CultureInfo.InvariantCulture,
  258. _localization.GetLocalizedString("LabelIpAddressValue"),
  259. session.RemoteEndPoint),
  260. }).ConfigureAwait(false);
  261. }
  262. private async void OnAuthenticationSucceeded(object sender, GenericEventArgs<AuthenticationResult> e)
  263. {
  264. var user = e.Argument.User;
  265. await CreateLogEntry(new ActivityLog(
  266. string.Format(
  267. CultureInfo.InvariantCulture,
  268. _localization.GetLocalizedString("AuthenticationSucceededWithUserName"),
  269. user.Name),
  270. "AuthenticationSucceeded",
  271. user.Id,
  272. DateTime.UtcNow,
  273. LogLevel.Trace)
  274. {
  275. ShortOverview = string.Format(
  276. CultureInfo.InvariantCulture,
  277. _localization.GetLocalizedString("LabelIpAddressValue"),
  278. e.Argument.SessionInfo.RemoteEndPoint),
  279. }).ConfigureAwait(false);
  280. }
  281. private async void OnAuthenticationFailed(object sender, GenericEventArgs<AuthenticationRequest> e)
  282. {
  283. await CreateLogEntry(new ActivityLog(
  284. string.Format(
  285. CultureInfo.InvariantCulture,
  286. _localization.GetLocalizedString("FailedLoginAttemptWithUserName"),
  287. e.Argument.Username),
  288. "AuthenticationFailed",
  289. Guid.Empty,
  290. DateTime.UtcNow,
  291. LogLevel.Error)
  292. {
  293. ShortOverview = string.Format(
  294. CultureInfo.InvariantCulture,
  295. _localization.GetLocalizedString("LabelIpAddressValue"),
  296. e.Argument.RemoteEndPoint),
  297. }).ConfigureAwait(false);
  298. }
  299. private async void OnUserPolicyUpdated(object sender, GenericEventArgs<User> e)
  300. {
  301. await CreateLogEntry(new ActivityLog(
  302. string.Format(
  303. CultureInfo.InvariantCulture,
  304. _localization.GetLocalizedString("UserPolicyUpdatedWithName"),
  305. e.Argument.Username),
  306. "UserPolicyUpdated",
  307. e.Argument.Id,
  308. DateTime.UtcNow,
  309. LogLevel.Trace))
  310. .ConfigureAwait(false);
  311. }
  312. private async void OnUserDeleted(object sender, GenericEventArgs<User> e)
  313. {
  314. await CreateLogEntry(new ActivityLog(
  315. string.Format(
  316. CultureInfo.InvariantCulture,
  317. _localization.GetLocalizedString("UserDeletedWithName"),
  318. e.Argument.Username),
  319. "UserDeleted",
  320. Guid.Empty,
  321. DateTime.UtcNow,
  322. LogLevel.Trace))
  323. .ConfigureAwait(false);
  324. }
  325. private async void OnUserPasswordChanged(object sender, GenericEventArgs<User> e)
  326. {
  327. await CreateLogEntry(new ActivityLog(
  328. string.Format(
  329. CultureInfo.InvariantCulture,
  330. _localization.GetLocalizedString("UserPasswordChangedWithName"),
  331. e.Argument.Username),
  332. "UserPasswordChanged",
  333. e.Argument.Id,
  334. DateTime.UtcNow,
  335. LogLevel.Trace)).ConfigureAwait(false);
  336. }
  337. private async void OnUserCreated(object sender, GenericEventArgs<User> e)
  338. {
  339. await CreateLogEntry(new ActivityLog(
  340. string.Format(
  341. CultureInfo.InvariantCulture,
  342. _localization.GetLocalizedString("UserCreatedWithName"),
  343. e.Argument.Username),
  344. "UserCreated",
  345. e.Argument.Id,
  346. DateTime.UtcNow,
  347. LogLevel.Trace))
  348. .ConfigureAwait(false);
  349. }
  350. private async void OnSessionStarted(object sender, SessionEventArgs e)
  351. {
  352. var session = e.SessionInfo;
  353. if (string.IsNullOrEmpty(session.UserName))
  354. {
  355. return;
  356. }
  357. await CreateLogEntry(new ActivityLog(
  358. string.Format(
  359. CultureInfo.InvariantCulture,
  360. _localization.GetLocalizedString("UserOnlineFromDevice"),
  361. session.UserName,
  362. session.DeviceName),
  363. "SessionStarted",
  364. session.UserId,
  365. DateTime.UtcNow,
  366. LogLevel.Trace)
  367. {
  368. ShortOverview = string.Format(
  369. CultureInfo.InvariantCulture,
  370. _localization.GetLocalizedString("LabelIpAddressValue"),
  371. session.RemoteEndPoint)
  372. }).ConfigureAwait(false);
  373. }
  374. private async void OnPluginUpdated(object sender, GenericEventArgs<(IPlugin, VersionInfo)> e)
  375. {
  376. await CreateLogEntry(new ActivityLog(
  377. string.Format(
  378. CultureInfo.InvariantCulture,
  379. _localization.GetLocalizedString("PluginUpdatedWithName"),
  380. e.Argument.Item1.Name),
  381. NotificationType.PluginUpdateInstalled.ToString(),
  382. Guid.Empty,
  383. DateTime.UtcNow,
  384. LogLevel.Trace)
  385. {
  386. ShortOverview = string.Format(
  387. CultureInfo.InvariantCulture,
  388. _localization.GetLocalizedString("VersionNumber"),
  389. e.Argument.Item2.version),
  390. Overview = e.Argument.Item2.changelog
  391. }).ConfigureAwait(false);
  392. }
  393. private async void OnPluginUninstalled(object sender, GenericEventArgs<IPlugin> e)
  394. {
  395. await CreateLogEntry(new ActivityLog(
  396. string.Format(
  397. CultureInfo.InvariantCulture,
  398. _localization.GetLocalizedString("PluginUninstalledWithName"),
  399. e.Argument.Name),
  400. NotificationType.PluginUninstalled.ToString(),
  401. Guid.Empty,
  402. DateTime.UtcNow,
  403. LogLevel.Trace))
  404. .ConfigureAwait(false);
  405. }
  406. private async void OnPluginInstalled(object sender, GenericEventArgs<VersionInfo> e)
  407. {
  408. await CreateLogEntry(new ActivityLog(
  409. string.Format(
  410. CultureInfo.InvariantCulture,
  411. _localization.GetLocalizedString("PluginInstalledWithName"),
  412. e.Argument.name),
  413. NotificationType.PluginInstalled.ToString(),
  414. Guid.Empty,
  415. DateTime.UtcNow,
  416. LogLevel.Trace)
  417. {
  418. ShortOverview = string.Format(
  419. CultureInfo.InvariantCulture,
  420. _localization.GetLocalizedString("VersionNumber"),
  421. e.Argument.version)
  422. }).ConfigureAwait(false);
  423. }
  424. private async void OnPackageInstallationFailed(object sender, InstallationFailedEventArgs e)
  425. {
  426. var installationInfo = e.InstallationInfo;
  427. await CreateLogEntry(new ActivityLog(
  428. string.Format(
  429. CultureInfo.InvariantCulture,
  430. _localization.GetLocalizedString("NameInstallFailed"),
  431. installationInfo.Name),
  432. NotificationType.InstallationFailed.ToString(),
  433. Guid.Empty,
  434. DateTime.UtcNow,
  435. LogLevel.Trace)
  436. {
  437. ShortOverview = string.Format(
  438. CultureInfo.InvariantCulture,
  439. _localization.GetLocalizedString("VersionNumber"),
  440. installationInfo.Version),
  441. Overview = e.Exception.Message
  442. }).ConfigureAwait(false);
  443. }
  444. private async void OnTaskCompleted(object sender, TaskCompletionEventArgs e)
  445. {
  446. var result = e.Result;
  447. var task = e.Task;
  448. if (task.ScheduledTask is IConfigurableScheduledTask activityTask
  449. && !activityTask.IsLogged)
  450. {
  451. return;
  452. }
  453. var time = result.EndTimeUtc - result.StartTimeUtc;
  454. var runningTime = string.Format(
  455. CultureInfo.InvariantCulture,
  456. _localization.GetLocalizedString("LabelRunningTimeValue"),
  457. ToUserFriendlyString(time));
  458. if (result.Status == TaskCompletionStatus.Failed)
  459. {
  460. var vals = new List<string>();
  461. if (!string.IsNullOrEmpty(e.Result.ErrorMessage))
  462. {
  463. vals.Add(e.Result.ErrorMessage);
  464. }
  465. if (!string.IsNullOrEmpty(e.Result.LongErrorMessage))
  466. {
  467. vals.Add(e.Result.LongErrorMessage);
  468. }
  469. await CreateLogEntry(new ActivityLog(
  470. string.Format(CultureInfo.InvariantCulture, _localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name),
  471. NotificationType.TaskFailed.ToString(),
  472. Guid.Empty,
  473. DateTime.UtcNow,
  474. LogLevel.Error)
  475. {
  476. Overview = string.Join(Environment.NewLine, vals),
  477. ShortOverview = runningTime
  478. }).ConfigureAwait(false);
  479. }
  480. }
  481. private async Task CreateLogEntry(ActivityLog entry)
  482. => await _activityManager.CreateAsync(entry).ConfigureAwait(false);
  483. /// <inheritdoc />
  484. public void Dispose()
  485. {
  486. _taskManager.TaskCompleted -= OnTaskCompleted;
  487. _installationManager.PluginInstalled -= OnPluginInstalled;
  488. _installationManager.PluginUninstalled -= OnPluginUninstalled;
  489. _installationManager.PluginUpdated -= OnPluginUpdated;
  490. _installationManager.PackageInstallationFailed -= OnPackageInstallationFailed;
  491. _sessionManager.SessionStarted -= OnSessionStarted;
  492. _sessionManager.AuthenticationFailed -= OnAuthenticationFailed;
  493. _sessionManager.AuthenticationSucceeded -= OnAuthenticationSucceeded;
  494. _sessionManager.SessionEnded -= OnSessionEnded;
  495. _sessionManager.PlaybackStart -= OnPlaybackStart;
  496. _sessionManager.PlaybackStopped -= OnPlaybackStopped;
  497. _subManager.SubtitleDownloadFailure -= OnSubtitleDownloadFailure;
  498. _userManager.OnUserCreated -= OnUserCreated;
  499. _userManager.OnUserPasswordChanged -= OnUserPasswordChanged;
  500. _userManager.OnUserDeleted -= OnUserDeleted;
  501. _userManager.OnUserLockedOut -= OnUserLockedOut;
  502. _deviceManager.CameraImageUploaded -= OnCameraImageUploaded;
  503. }
  504. /// <summary>
  505. /// Constructs a user-friendly string for this TimeSpan instance.
  506. /// </summary>
  507. private static string ToUserFriendlyString(TimeSpan span)
  508. {
  509. const int DaysInYear = 365;
  510. const int DaysInMonth = 30;
  511. // Get each non-zero value from TimeSpan component
  512. var values = new List<string>();
  513. // Number of years
  514. int days = span.Days;
  515. if (days >= DaysInYear)
  516. {
  517. int years = days / DaysInYear;
  518. values.Add(CreateValueString(years, "year"));
  519. days = days % DaysInYear;
  520. }
  521. // Number of months
  522. if (days >= DaysInMonth)
  523. {
  524. int months = days / DaysInMonth;
  525. values.Add(CreateValueString(months, "month"));
  526. days = days % DaysInMonth;
  527. }
  528. // Number of days
  529. if (days >= 1)
  530. {
  531. values.Add(CreateValueString(days, "day"));
  532. }
  533. // Number of hours
  534. if (span.Hours >= 1)
  535. {
  536. values.Add(CreateValueString(span.Hours, "hour"));
  537. }
  538. // Number of minutes
  539. if (span.Minutes >= 1)
  540. {
  541. values.Add(CreateValueString(span.Minutes, "minute"));
  542. }
  543. // Number of seconds (include when 0 if no other components included)
  544. if (span.Seconds >= 1 || values.Count == 0)
  545. {
  546. values.Add(CreateValueString(span.Seconds, "second"));
  547. }
  548. // Combine values into string
  549. var builder = new StringBuilder();
  550. for (int i = 0; i < values.Count; i++)
  551. {
  552. if (builder.Length > 0)
  553. {
  554. builder.Append(i == values.Count - 1 ? " and " : ", ");
  555. }
  556. builder.Append(values[i]);
  557. }
  558. // Return result
  559. return builder.ToString();
  560. }
  561. /// <summary>
  562. /// Constructs a string description of a time-span value.
  563. /// </summary>
  564. /// <param name="value">The value of this item.</param>
  565. /// <param name="description">The name of this item (singular form).</param>
  566. private static string CreateValueString(int value, string description)
  567. {
  568. return string.Format(
  569. CultureInfo.InvariantCulture,
  570. "{0:#,##0} {1}",
  571. value,
  572. value == 1 ? description : string.Format(CultureInfo.InvariantCulture, "{0}s", description));
  573. }
  574. }
  575. }