Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions EditorReaderHarness/EditorReaderHarness.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<!--
临时诊断工程:只用于测量 EditorReader 的真实开销与失败原因。
不引用主工程,而是直接链接主工程的 EditorReader 源码(同一份实现,不含 UI/设置依赖),
这样测出来的数字就是主程序跑出来的数字。测试结束后整个目录可以删除。
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows7.0</TargetFramework>
<RootNamespace>EditorReaderHarness</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AssemblyName>EditorReaderHarness</AssemblyName>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\osucatch-editor-realtimeviewer\EditorReader\*.cs" LinkBase="EditorReader" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions EditorReaderHarness/Log.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace osucatch_editor_realtimeviewer
{
/// <summary>
/// 主工程 Log 的替身:EditorReader 的内部错误日志走到这里。
/// 默认只累计计数,避免在计时循环里往控制台写 IO 把数字带偏。
/// </summary>
public static class Log
{
public enum LogType { Default, Program, EditorReader, BeatmapBuilder, BeatmapConverter, Drawing, Backup, Timer, Bookmark }

public enum LogLevel { Debug, Info, Warning, Error }

public static long Count;

public static bool Echo;

public static readonly List<string> Recent = new();

public static void ConsoleLog(string msg, LogType logType = LogType.Default, LogLevel logLevel = LogLevel.Info)
{
Interlocked.Increment(ref Count);
lock (Recent)
{
if (Recent.Count < 200)
{
Recent.Add("[" + logLevel + "][" + logType + "] " + msg);
}
}

if (Echo)
{
Console.WriteLine(" [osu-reader] " + logLevel + ": " + msg);
}
}

public static void Breadcrumb(string msg) => ConsoleLog(msg, LogType.Program, LogLevel.Debug);
}
}
Loading
Loading