Compare commits

..

4 Commits

Author SHA1 Message Date
f1b696ad5e
Supports uploading logs to the server.
支持上传日志到服务器。
2024-07-15 22:17:43 +08:00
c4889d67b6 提交Demo。 2024-07-13 21:05:40 +08:00
b84fa3da0b Merge branch 'master' of https://git.coldmint.top/Cold-Mint/Traveller 2024-07-12 20:10:55 +08:00
750e7860ec 临时保存 2024-07-11 20:29:04 +08:00
3 changed files with 160 additions and 136 deletions

View File

@ -10,6 +10,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" /> <PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="YamlDotNet" Version="15.1.6" /> <PackageReference Include="YamlDotNet" Version="15.1.6" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,6 +4,9 @@ using System.Text;
using ColdMint.scripts.openObserve; using ColdMint.scripts.openObserve;
using ColdMint.scripts.utils; using ColdMint.scripts.utils;
using Godot; using Godot;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Exporter;
using OpenTelemetry.Logs;
namespace ColdMint.scripts.debug; namespace ColdMint.scripts.debug;
@ -116,6 +119,25 @@ public static class LogCat
private static HashSet<string> DisabledLogLabels { get; } = []; private static HashSet<string> DisabledLogLabels { get; } = [];
public static void Init()
{
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddOpenTelemetry(options => { options.AddOtlpExporter(OtlpExporterOptions); });
});
var logger = loggerFactory.CreateLogger("323");
logger.Log(LogLevel.Debug, "你好");
}
public static void OtlpExporterOptions(OtlpExporterOptions options)
{
options.Protocol = OtlpExportProtocol.HttpProtobuf;
options.Endpoint = new Uri("http://test.coldmint.top/api/default/traces");
options.Headers =
"Authorization=Basic cm9vdEBleGFtcGxlLmNvbTp5V0kwVzZYcWhteTBzQml3,organization=default,stream-name=default";
}
/// <summary> /// <summary>
/// <para>Disable log Label</para> /// <para>Disable log Label</para>
/// <para>禁用某个日志标签</para> /// <para>禁用某个日志标签</para>