using ColdMint.scripts.debug; using ColdMint.scripts.openObserve; using ColdMint.scripts.serialization; using Godot; namespace ColdMint.scripts; public class AppConfig { /// /// Load configuration from file /// 从文件加载配置 /// 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(yamlData); } /// /// ApplyAppConfig /// 应用配置 /// /// public static void ApplyAppConfig(AppConfigData appConfigData) { if (appConfigData.OpenObserve != null) { LogCollector.UpdateHttpClient(appConfigData.OpenObserve); } } } public class AppConfigData { /// /// OpenObserve configuration information /// OpenObserve的配置信息 /// public OpenObserve? OpenObserve { get; set; } } /// /// OpenObserve Configuration information /// OpenObserve配置信息 /// public class OpenObserve { /// /// server address /// 服务器地址 /// public string? Address { get; set; } /// /// Access Token /// 访问密匙 /// public string? AccessToken { get; set; } /// /// Organization ID /// 组织ID /// public string? OrgId { get; set; } }