新增:release版本日志打印开关

This commit is contained in:
ivan 2026-04-28 11:20:07 +08:00
parent 8455c3946b
commit cd6a9ade0a
3 changed files with 20 additions and 6 deletions

View File

@ -2,8 +2,18 @@ import 'package:flutter/foundation.dart';
/// petsHeroAI API 配置
abstract final class ApiConfig {
/// 调试日志:true 时 release 包也输出 debug/info(正式包调试用,上线前改 false)
static const bool debugLogs = false;
/// 运行时日志级别,由编译时注入,例如:
/// `flutter run --release --dart-define=APP_LOG_LEVEL=trace`
/// 为 `trace` / `debug` / `verbose` 时,release 包也会输出全量调试日志([AppLogger]、代理请求日志等)。
static const String appLogLevel =
String.fromEnvironment('APP_LOG_LEVEL', defaultValue: '');
/// 与 debug 模式相同:全量应用日志。release 下仅当 [appLogLevel] 为 trace/debug/verbose 时为 true。
static bool get debugLogs {
if (kDebugMode) return true;
final l = appLogLevel.toLowerCase();
return l == 'trace' || l == 'debug' || l == 'verbose';
}
/// AES 密钥
static const String aesKey = 'liyP4LkMfP68XvCt';

View File

@ -1,9 +1,13 @@
import 'package:flutter/foundation.dart';
import '../api/api_config.dart';
/// Facebook SDK 配置
///
/// 用于 Adjust Meta Install Referrer 归因与 Facebook App Events 埋点。
abstract final class FacebookConfig {
/// Facebook 调试日志:true 时 Dart 层会打印所有 FB 事件(正式包调试用,上线前改 false)
static const bool debugLogs = true;
/// Dart 层 FB 事件控制台日志:debug 构建或 `--dart-define=APP_LOG_LEVEL=trace` 等为 true。
static bool get debugLogs => kDebugMode || ApiConfig.debugLogs;
/// Facebook 应用 ID(应用编号)
static const String appId = '1684216162986495';

View File

@ -6,8 +6,8 @@ import '../api/api_config.dart';
/// 统一应用日志,提升可读性:时间戳、级别、标签、格式化输出。
///
/// [Logger] 默认 [DevelopmentFilter] 依赖 `assert`,在 release/profile 下会屏蔽**全部**日志。
/// 正式包排障时设 [ApiConfig.debugLogs]=true,此处改用 [ProductionFilter] 才可见 debug/info。
/// release 且 debugLogs=false 时仍不输出(warning 也会被 filter 掉,与原先行为一致)。
/// Release 全量日志:`flutter run --release --dart-define=APP_LOG_LEVEL=trace`(见 [ApiConfig.debugLogs])。
/// 此时使用 [ProductionFilter],debug/info 可见。
///
/// 使用示例:
/// final _log = AppLogger('GenerateVideo');