测试上传成功。
This commit is contained in:
parent
0cbb082cbb
commit
eba74c4ed4
|
@ -1,3 +1,4 @@
|
||||||
open_observe:
|
open_observe:
|
||||||
address: [address]
|
address: http://test.coldmint.top/
|
||||||
access_token: [token]
|
access_token: 我的Token
|
||||||
|
org_id: default
|
|
@ -23,7 +23,7 @@ log_player_packed_scene_not_exist,玩家预制场景不存在。,Player packed s
|
||||||
log_exit_the_room_debug,节点{0}退出房间{1}。,"Node {0} exits room {1}.",ノード{0}が部屋{1}を退出します。
|
log_exit_the_room_debug,节点{0}退出房间{1}。,"Node {0} exits room {1}.",ノード{0}が部屋{1}を退出します。
|
||||||
log_enter_the_room_debug,节点{0}进入房间{1}。,"Node {0} enters room {1}.",ノード{0}が部屋{1}に入ります。
|
log_enter_the_room_debug,节点{0}进入房间{1}。,"Node {0} enters room {1}.",ノード{0}が部屋{1}に入ります。
|
||||||
log_death_info,生物{0}被{1}击败。,"Creature {0} was defeated by {1}.",生物{0}が{1}によって打ち負かされました。
|
log_death_info,生物{0}被{1}击败。,"Creature {0} was defeated by {1}.",生物{0}が{1}によって打ち負かされました。
|
||||||
|
log_appConfig_not_exist,您可以在项目根目录创建名为AppConfig.yaml的文件,并在其中配置OpenObserve的数据,以便在游戏发布后持续收集日志和运行数据。,You can create a file named AppConfig.yaml in the project root directory and configure OpenObserve data in it to collect log and run data continuously after the game has been released.,プロジェクトのルートディレクトリにappconfig.yamlというファイルを作成し、そこにOpenObserveのデータを配置して、リリース後も継続的にログや実行データを収集することができます。
|
||||||
log_loot_list_has_no_entries,ID为{0}的战利品表,没有指定条目。,"Loot list with ID {0}, no entry specified.",ID{0}の戦利品テーブルは、エントリ指定されていません。
|
log_loot_list_has_no_entries,ID为{0}的战利品表,没有指定条目。,"Loot list with ID {0}, no entry specified.",ID{0}の戦利品テーブルは、エントリ指定されていません。
|
||||||
log_not_within_the_loot_spawn_range,给定的数值{0}没有在战利品{1}的生成范围{2}内。,The given value {0} is not within the spawn range {2} of loot {1}.,与えられた数値{0}は戦利品{1}の生成範囲{2}内にありません。
|
log_not_within_the_loot_spawn_range,给定的数值{0}没有在战利品{1}的生成范围{2}内。,The given value {0} is not within the spawn range {2} of loot {1}.,与えられた数値{0}は戦利品{1}の生成範囲{2}内にありません。
|
||||||
log_loot_data_quantity,有{0}个战利品数据被返回。,{0} loot data was returned.,{0}個の戦利品データが返されます。
|
log_loot_data_quantity,有{0}个战利品数据被返回。,{0} loot data was returned.,{0}個の戦利品データが返されます。
|
||||||
|
|
|
76
scripts/AppConfig.cs
Normal file
76
scripts/AppConfig.cs
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
using ColdMint.scripts.debug;
|
||||||
|
using ColdMint.scripts.openObserve;
|
||||||
|
using ColdMint.scripts.serialization;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace ColdMint.scripts;
|
||||||
|
|
||||||
|
public class AppConfig
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Load configuration from file</para>
|
||||||
|
/// <para>从文件加载配置</para>
|
||||||
|
/// </summary>
|
||||||
|
public static AppConfigData? LoadFromFile()
|
||||||
|
{
|
||||||
|
var appConfigExists = FileAccess.FileExists(Config.AppConfigPath);
|
||||||
|
if (!appConfigExists)
|
||||||
|
{
|
||||||
|
LogCat.LogWarning("appConfig_not_exist");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var appConfigFileAccess = FileAccess.Open(Config.AppConfigPath, FileAccess.ModeFlags.Read);
|
||||||
|
var yamlData = appConfigFileAccess.GetAsText();
|
||||||
|
appConfigFileAccess.Close();
|
||||||
|
return YamlSerialization.Deserialize<AppConfigData>(yamlData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>ApplyAppConfig</para>
|
||||||
|
/// <para>应用配置</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appConfigData"></param>
|
||||||
|
public static void ApplyAppConfig(AppConfigData appConfigData)
|
||||||
|
{
|
||||||
|
if (appConfigData.OpenObserve != null)
|
||||||
|
{
|
||||||
|
LogCollector.UpdateHttpClient(appConfigData.OpenObserve);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AppConfigData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>OpenObserve configuration information</para>
|
||||||
|
/// <para>OpenObserve的配置信息</para>
|
||||||
|
/// </summary>
|
||||||
|
public OpenObserve? OpenObserve { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>OpenObserve Configuration information</para>
|
||||||
|
/// <para>OpenObserve配置信息</para>
|
||||||
|
/// </summary>
|
||||||
|
public class OpenObserve
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>server address</para>
|
||||||
|
/// <para>服务器地址</para>
|
||||||
|
/// </summary>
|
||||||
|
public string? Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Access Token</para>
|
||||||
|
/// <para>访问密匙</para>
|
||||||
|
/// </summary>
|
||||||
|
public string? AccessToken { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Organization ID</para>
|
||||||
|
/// <para>组织ID</para>
|
||||||
|
/// </summary>
|
||||||
|
public string? OrgId { get; set; }
|
||||||
|
}
|
|
@ -85,6 +85,12 @@ public static class Config
|
||||||
public const string Aborigines = "Aborigines";
|
public const string Aborigines = "Aborigines";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Path of the App configuration file</para>
|
||||||
|
/// <para>App配置文件路径</para>
|
||||||
|
/// </summary>
|
||||||
|
public const string AppConfigPath = "res://AppConfig.yaml";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>The percentage of speed reduced after a thrown item hits an enemy</para>
|
/// <para>The percentage of speed reduced after a thrown item hits an enemy</para>
|
||||||
/// <para>抛出的物品击中敌人后减少的速度百分比</para>
|
/// <para>抛出的物品击中敌人后减少的速度百分比</para>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using ColdMint.scripts.openObserve;
|
||||||
using ColdMint.scripts.utils;
|
using ColdMint.scripts.utils;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
|
@ -206,7 +207,13 @@ public static class LogCat
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GD.Print(HandleMessage(InfoLogLevel, message, label));
|
|
||||||
|
var msg = HandleMessage(InfoLogLevel, message, label);
|
||||||
|
var logData = new LogData();
|
||||||
|
logData.Message = msg.ToString();
|
||||||
|
logData.AppId = "test";
|
||||||
|
LogCollector.Push(logData);
|
||||||
|
GD.Print(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -20,148 +20,154 @@ namespace ColdMint.scripts.loader.uiLoader;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainMenuLoader : UiLoaderTemplate
|
public partial class MainMenuLoader : UiLoaderTemplate
|
||||||
{
|
{
|
||||||
private Button? _startGameButton;
|
private Button? _startGameButton;
|
||||||
private Label? _copyrightLabel;
|
private Label? _copyrightLabel;
|
||||||
private StringBuilder? _copyrightBuilder;
|
private StringBuilder? _copyrightBuilder;
|
||||||
private PackedScene? _gameScene;
|
private PackedScene? _gameScene;
|
||||||
private PackedScene? _contributor;
|
private PackedScene? _contributor;
|
||||||
private PackedScene? _levelGraphEditor;
|
private PackedScene? _levelGraphEditor;
|
||||||
private Label? _sloganLabel;
|
private Label? _sloganLabel;
|
||||||
private Label? _versionLabel;
|
private Label? _versionLabel;
|
||||||
private Button? _levelGraphEditorButton;
|
private Button? _levelGraphEditorButton;
|
||||||
private LinkButton? _contributorButton;
|
private LinkButton? _contributorButton;
|
||||||
|
|
||||||
public override void InitializeData()
|
public override void InitializeData()
|
||||||
{
|
{
|
||||||
if (Config.IsDebug())
|
AppConfigData? appConfigData = AppConfig.LoadFromFile();
|
||||||
{
|
if (appConfigData != null)
|
||||||
//Set the minimum log level to Info in debug mode.(Print all logs)
|
{
|
||||||
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
AppConfig.ApplyAppConfig(appConfigData);
|
||||||
LogCat.MinLogLevel = LogCat.InfoLogLevel;
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Disable all logs in the release version.
|
|
||||||
//在发行版禁用所有日志。
|
|
||||||
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContributorDataManager.RegisterAllContributorData();
|
if (Config.IsDebug())
|
||||||
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
{
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
//Set the minimum log level to Info in debug mode.(Print all logs)
|
||||||
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
//在调试模式下将最小日志等级设置为Info。(打印全部日志)
|
||||||
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
LogCat.MinLogLevel = LogCat.InfoLogLevel;
|
||||||
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
}
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
else
|
||||||
//创建游戏数据文件夹
|
{
|
||||||
var dataPath = Config.GetGameDataDirectory();
|
//Disable all logs in the release version.
|
||||||
if (!Directory.Exists(dataPath))
|
//在发行版禁用所有日志。
|
||||||
{
|
LogCat.MinLogLevel = LogCat.DisableAllLogLevel;
|
||||||
Directory.CreateDirectory(dataPath);
|
}
|
||||||
}
|
|
||||||
|
ContributorDataManager.RegisterAllContributorData();
|
||||||
|
DeathInfoGenerator.RegisterDeathInfoHandler(new SelfDeathInfoHandler());
|
||||||
|
MapGenerator.RegisterRoomInjectionProcessor(new ChanceRoomInjectionProcessor());
|
||||||
|
MapGenerator.RegisterRoomInjectionProcessor(new TimeIntervalRoomInjectorProcessor());
|
||||||
|
//Register the corresponding encoding provider to solve the problem of garbled Chinese path of the compressed package
|
||||||
|
//注册对应的编码提供程序,解决压缩包中文路径乱码问题
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
//创建游戏数据文件夹
|
||||||
|
var dataPath = Config.GetGameDataDirectory();
|
||||||
|
if (!Directory.Exists(dataPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(dataPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Registered camp
|
//Registered camp
|
||||||
//注册阵营
|
//注册阵营
|
||||||
var defaultCamp = new Camp(Config.CampId.Default)
|
var defaultCamp = new Camp(Config.CampId.Default)
|
||||||
{
|
{
|
||||||
FriendInjury = true
|
FriendInjury = true
|
||||||
};
|
};
|
||||||
CampManager.SetDefaultCamp(defaultCamp);
|
CampManager.SetDefaultCamp(defaultCamp);
|
||||||
var mazoku = new Camp(Config.CampId.Mazoku);
|
var mazoku = new Camp(Config.CampId.Mazoku);
|
||||||
CampManager.AddCamp(mazoku);
|
CampManager.AddCamp(mazoku);
|
||||||
var aborigines = new Camp(Config.CampId.Aborigines);
|
var aborigines = new Camp(Config.CampId.Aborigines);
|
||||||
CampManager.AddCamp(aborigines);
|
CampManager.AddCamp(aborigines);
|
||||||
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
_gameScene = GD.Load<PackedScene>("res://scenes/game.tscn");
|
||||||
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
_contributor = GD.Load<PackedScene>("res://scenes/contributor.tscn");
|
||||||
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
_levelGraphEditor = GD.Load<PackedScene>("res://scenes/levelGraphEditor.tscn");
|
||||||
|
|
||||||
//Register ItemTypes from file
|
//Register ItemTypes from file
|
||||||
//从文件注册物品类型
|
//从文件注册物品类型
|
||||||
ItemTypeRegister.RegisterFromFile();
|
ItemTypeRegister.RegisterFromFile();
|
||||||
//Hardcoded ItemTypes Register
|
//Hardcoded ItemTypes Register
|
||||||
//硬编码注册物品类型
|
//硬编码注册物品类型
|
||||||
ItemTypeRegister.StaticRegister();
|
ItemTypeRegister.StaticRegister();
|
||||||
|
|
||||||
//静态注册掉落表
|
//静态注册掉落表
|
||||||
LootRegister.StaticRegister();
|
LootRegister.StaticRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void InitializeUi()
|
public override void InitializeUi()
|
||||||
{
|
{
|
||||||
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
_contributorButton = GetNode<LinkButton>("VBoxContainer2/ContributorButton");
|
||||||
_startGameButton = GetNode<Button>("StartGameButton");
|
_startGameButton = GetNode<Button>("StartGameButton");
|
||||||
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
_levelGraphEditorButton = GetNode<Button>("levelGraphEditorButton");
|
||||||
//The level map editor is only available in debug mode.
|
//The level map editor is only available in debug mode.
|
||||||
//关卡图编辑器仅在调试模式可用。
|
//关卡图编辑器仅在调试模式可用。
|
||||||
_levelGraphEditorButton.Visible = Config.IsDebug();
|
_levelGraphEditorButton.Visible = Config.IsDebug();
|
||||||
_startGameButton.GrabFocus();
|
_startGameButton.GrabFocus();
|
||||||
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
_versionLabel = GetNode<Label>("VBoxContainer2/VersionLabel");
|
||||||
//Generative copyright
|
//Generative copyright
|
||||||
//生成版权
|
//生成版权
|
||||||
_copyrightLabel = GetNode<Label>("VBoxContainer/CopyrightLabel");
|
_copyrightLabel = GetNode<Label>("VBoxContainer/CopyrightLabel");
|
||||||
_sloganLabel = GetNode<Label>("CenterContainer2/SloganLabel");
|
_sloganLabel = GetNode<Label>("CenterContainer2/SloganLabel");
|
||||||
_copyrightBuilder = new StringBuilder();
|
_copyrightBuilder = new StringBuilder();
|
||||||
_copyrightBuilder.Append('\u00a9');
|
_copyrightBuilder.Append('\u00a9');
|
||||||
var currentYear = DateTime.Now.Year;
|
var currentYear = DateTime.Now.Year;
|
||||||
_copyrightBuilder.Append(Config.CreationYear);
|
_copyrightBuilder.Append(Config.CreationYear);
|
||||||
if (currentYear != Config.CreationYear)
|
if (currentYear != Config.CreationYear)
|
||||||
{
|
{
|
||||||
_copyrightBuilder.Append('-');
|
_copyrightBuilder.Append('-');
|
||||||
_copyrightBuilder.Append(currentYear);
|
_copyrightBuilder.Append(currentYear);
|
||||||
}
|
}
|
||||||
|
|
||||||
_copyrightBuilder.Append(' ');
|
_copyrightBuilder.Append(' ');
|
||||||
_copyrightBuilder.Append(Config.CompanyName);
|
_copyrightBuilder.Append(Config.CompanyName);
|
||||||
_copyrightBuilder.Append(" all rights reserved.");
|
_copyrightBuilder.Append(" all rights reserved.");
|
||||||
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
_copyrightLabel.Text = _copyrightBuilder.ToString();
|
||||||
_versionLabel.Text = "ver." + Config.GetVersion();
|
_versionLabel.Text = "ver." + Config.GetVersion();
|
||||||
_sloganLabel.Text = SloganProvider.GetSlogan();
|
_sloganLabel.Text = SloganProvider.GetSlogan();
|
||||||
_contributorButton.Text =
|
_contributorButton.Text =
|
||||||
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
TranslationServerUtils.TranslateWithFormat("ui_contributor_tips",
|
||||||
ContributorDataManager.GetContributorTotals());
|
ContributorDataManager.GetContributorTotals());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void LoadUiActions()
|
public override void LoadUiActions()
|
||||||
{
|
{
|
||||||
if (_startGameButton != null)
|
if (_startGameButton != null)
|
||||||
{
|
{
|
||||||
_startGameButton.Pressed += () =>
|
_startGameButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
if (_gameScene == null)
|
if (_gameScene == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_gameScene);
|
GetTree().ChangeSceneToPacked(_gameScene);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_contributorButton != null)
|
if (_contributorButton != null)
|
||||||
{
|
{
|
||||||
_contributorButton.Pressed += () =>
|
_contributorButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
if (_contributor == null)
|
if (_contributor == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_contributor);
|
GetTree().ChangeSceneToPacked(_contributor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_levelGraphEditorButton != null)
|
if (_levelGraphEditorButton != null)
|
||||||
{
|
{
|
||||||
_levelGraphEditorButton.Pressed += () =>
|
_levelGraphEditorButton.Pressed += () =>
|
||||||
{
|
{
|
||||||
LogCat.Log("level_graph_editor");
|
LogCat.Log("level_graph_editor");
|
||||||
if (_levelGraphEditor == null)
|
if (_levelGraphEditor == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
GetTree().ChangeSceneToPacked(_levelGraphEditor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
116
scripts/openObserve/LogCollector.cs
Normal file
116
scripts/openObserve/LogCollector.cs
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ColdMint.scripts.debug;
|
||||||
|
using Godot;
|
||||||
|
using HttpClient = System.Net.Http.HttpClient;
|
||||||
|
|
||||||
|
namespace ColdMint.scripts.openObserve;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>LogCollector</para>
|
||||||
|
/// <para>日志收集器</para>
|
||||||
|
/// </summary>
|
||||||
|
public static class LogCollector
|
||||||
|
{
|
||||||
|
private static readonly List<LogData> _logDataList = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Automatic upload threshold</para>
|
||||||
|
/// <para>自动上传的阈值</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///<para>An attempt is made to upload logs when messages reach this number.</para>
|
||||||
|
///<para>当消息到达此数量后将尝试上传日志。</para>
|
||||||
|
/// </remarks>
|
||||||
|
public static int UploadThreshold { get; set; } = 50;
|
||||||
|
|
||||||
|
private static bool lockList = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>httpClient</para>
|
||||||
|
/// <para>Http客户</para>
|
||||||
|
/// </summary>
|
||||||
|
private static HttpClient? _httpClient;
|
||||||
|
|
||||||
|
private static string? _orgId;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>UpdateHttpClient</para>
|
||||||
|
/// <para>更新Http客户端</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="openObserve"></param>
|
||||||
|
public static void UpdateHttpClient(OpenObserve openObserve)
|
||||||
|
{
|
||||||
|
if (openObserve.Address == null || openObserve.AccessToken == null || openObserve.OrgId == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
httpClient.BaseAddress = new Uri(openObserve.Address);
|
||||||
|
//Add a Cookie to the request header
|
||||||
|
//添加Cookie到请求头
|
||||||
|
var cookie = new Cookie("auth_tokens",
|
||||||
|
"{\"access_token\":\"Basic " + openObserve.AccessToken + "\",\"refresh_token\":\"\"}");
|
||||||
|
httpClient.DefaultRequestHeaders.Add("Cookie", cookie.ToString());
|
||||||
|
_httpClient = httpClient;
|
||||||
|
_orgId = openObserve.OrgId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Push log</para>
|
||||||
|
/// <para>推送日志</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logRequestBean"></param>
|
||||||
|
private static async Task PostLog(List<LogData> logRequestBean)
|
||||||
|
{
|
||||||
|
if (_httpClient == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lockList = true;
|
||||||
|
GD.Print("开始上传");
|
||||||
|
var httpResponseMessage = await _httpClient.PostAsJsonAsync("/api/" + _orgId + "/game/_json", logRequestBean);
|
||||||
|
if (httpResponseMessage.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
_logDataList.RemoveRange(0, logRequestBean.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GD.Print("上传失败" + httpResponseMessage.StatusCode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
lockList = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Push(LogData logData)
|
||||||
|
{
|
||||||
|
_logDataList.Add(logData);
|
||||||
|
GD.Print("上传吗" + lockList + "长度为" + _logDataList.Count + "阈值" + UploadThreshold);
|
||||||
|
if (!lockList && _logDataList.Count > UploadThreshold)
|
||||||
|
{
|
||||||
|
//执行上传
|
||||||
|
GD.Print("上传");
|
||||||
|
PostLog(_logDataList.GetRange(0, UploadThreshold));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LogData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// <para>The AppId of this application</para>
|
||||||
|
/// <para>此应用的AppId</para>
|
||||||
|
/// </summary>
|
||||||
|
public string? AppId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>message</para>
|
||||||
|
/// <para>消息</para>
|
||||||
|
/// </summary>
|
||||||
|
public string? Message { get; set; }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user