Merge pull request #7900 from ivandrofly/feature/logger

Feature/logger
This commit is contained in:
Nikolaj Olsson 2024-02-03 18:30:24 +01:00 committed by GitHub
commit 7fe11340e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 34 deletions

View File

@ -7,7 +7,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{ {
public static class SeLogger public static class SeLogger
{ {
public static string ErrorFile => Path.Combine(Configuration.DataDirectory, "error_log.txt"); public static string ErrorFile => Path.Combine(Configuration.DataDirectory, "error_log.txt");
public static void Error(Exception exception, string message = null) public static void Error(Exception exception, string message = null)
@ -102,7 +101,16 @@ namespace Nikse.SubtitleEdit.Core.Common
return Path.Combine(Configuration.DataDirectory, "whisper_log.txt"); return Path.Combine(Configuration.DataDirectory, "whisper_log.txt");
} }
private static string GetSeInfo() /// <summary>
/// Get information about the machine that is cached and accessed by the SeLogger class.
/// </summary>
/// <returns>A string representing information about the machine.</returns>
private static string GetSeInfo() => CachedMachineInfo.Value;
/// <summary>
/// Represents information about the machine that is cached and accessed by the <see cref="SeLogger"/> class.
/// </summary>
private static readonly Lazy<string> CachedMachineInfo = new Lazy<string>(() =>
{ {
try try
{ {
@ -112,6 +120,6 @@ namespace Nikse.SubtitleEdit.Core.Common
{ {
return string.Empty; return string.Empty;
} }
} });
} }
} }

View File

@ -1,30 +0,0 @@
using System;
namespace Nikse.SubtitleEdit.Core.Common.TextLengthCalculator
{
public static class TextLengthHelper
{
public static decimal CountCharacters(string text, bool forCps)
{
return CalcFactory.MakeCalculator(Configuration.Settings.General.CpsLineLengthStrategy).CountCharacters(text, forCps);
}
public static bool IsKnownHtmlTag(string input, int index)
{
var s = input.Remove(0, index + 1).ToLowerInvariant();
return s.StartsWith('/') ||
s.StartsWith("i>", StringComparison.Ordinal) ||
s.StartsWith("b>", StringComparison.Ordinal) ||
s.StartsWith("u>", StringComparison.Ordinal) ||
s.StartsWith("font ", StringComparison.Ordinal) ||
s.StartsWith("ruby", StringComparison.Ordinal) ||
s.StartsWith("span>", StringComparison.Ordinal) ||
s.StartsWith("span ", StringComparison.Ordinal) ||
s.StartsWith("p>", StringComparison.Ordinal) ||
s.StartsWith("br>", StringComparison.Ordinal) ||
s.StartsWith("box>", StringComparison.Ordinal) ||
s.StartsWith("div>", StringComparison.Ordinal) ||
s.StartsWith("div ", StringComparison.Ordinal);
}
}
}