feat: implement InterpolatedStringHandler for Logger, replace Func<string> lambda overloads

Agent-Logs-Url: https://github.com/Meloong-Git/MeloongCore/sessions/186510eb-a481-4e72-b83d-a3e77c103fc6

Co-authored-by: LTCatt <40348278+LTCatt@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]andLTCatt authored and GitHub committed 2026-05-07 04:21:38 +00:00
1 parent e391dd22b6
commit 4e07bcf17a
2 files changed
+165 -14

No files matched your search

+4 -4
View File
@@ -26,7 +26,7 @@ public static class FileUtils {
/// </summary>
public static void Write(string filePath, byte[] content) {
DirectoryUtils.Create(filePath, isFilePath: true);
Logger.Trace(() => $"写入文件:{filePath}({content.Length} 字节)");
Logger.Trace($"写入文件:{filePath}({content.Length} 字节)");
File.WriteAllBytes(PathUtils.WithLongPath(filePath), content);
}
@@ -38,7 +38,7 @@ public static class FileUtils {
public static void Write(string filePath, Stream stream) {
using FileStream fileStream = FileUtils.CreateAsStream(filePath);
if (stream.CanSeek && stream.Position != 0) stream.Seek(0, SeekOrigin.Begin);
Logger.Trace(() => $"写入文件:{filePath}({stream.GetType().Name}{(stream.CanSeek ? $" {stream.Length} 字节" : "")})");
Logger.Trace($"写入文件:{filePath}({stream.GetType().Name}{(stream.CanSeek ? $" {stream.Length} 字节" : "")})");
stream.CopyTo(fileStream);
}
@@ -155,7 +155,7 @@ public static class FileUtils {
/// </summary>
public static ZipArchive OpenZip(string zipFilePath) {
ZipArchive TryOpen(Encoding encoding) {
Logger.Trace(() => $"尝试以 {encoding.EncodingName} 编码打开压缩包:{zipFilePath}");
Logger.Trace($"尝试以 {encoding.EncodingName} 编码打开压缩包:{zipFilePath}");
var result = ZipFile.Open(PathUtils.WithLongPath(zipFilePath), ZipArchiveMode.Read, encoding);
try {
_ = result.Entries; // 如果编码有误,会在这里抛出 DecoderFallbackException;如果文件异常,会在这里抛出 InvalidDataException
@@ -251,7 +251,7 @@ public static class FileUtils {
DirectoryUtils.Create(outputFullPath, isFilePath: true);
FileUtils.Delete(outputFullPath);
using var archive = ZipFile.Open(outputFullPath, ZipArchiveMode.Create);
Logger.Trace(() => $"创建 zip 文件:{sources.Count} 个文件 → {outputFullPath}\n{sources.Select(p => $"- {p.Value} → {p.Key}").Join('\n')}");
Logger.Trace($"创建 zip 文件:{sources.Count} 个文件 → {outputFullPath}\n{sources.Select(p => $"- {p.Value} → {p.Key}").Join('\n')}");
foreach (var pair in sources) archive.CreateEntryFromFile(PathUtils.WithLongPath(pair.Value), pair.Key.Replace('\\', '/'), CompressionLevel.Optimal);
}