新增:日志开关
This commit is contained in:
parent
79d4e32e3e
commit
26caaa46ac
@ -13,6 +13,7 @@ import '../config/facebook_config.dart';
|
||||
abstract final class AdjustEvents {
|
||||
static final _fb = FacebookAppEvents();
|
||||
static final _fbLog = Logger(
|
||||
filter: FacebookConfig.debugLogs ? ProductionFilter() : DevelopmentFilter(),
|
||||
printer: PrettyPrinter(methodCount: 0, lineLength: 120),
|
||||
level: FacebookConfig.debugLogs ? Level.trace : Level.off,
|
||||
);
|
||||
|
||||
@ -4,7 +4,10 @@ import 'package:logger/logger.dart';
|
||||
import '../api/api_config.dart';
|
||||
|
||||
/// 统一应用日志,提升可读性:时间戳、级别、标签、格式化输出。
|
||||
/// release 下默认仅输出 warning/error;ApiConfig.debugLogs=true 时放开全部级别。
|
||||
///
|
||||
/// [Logger] 默认 [DevelopmentFilter] 依赖 `assert`,在 release/profile 下会屏蔽**全部**日志。
|
||||
/// 正式包排障时设 [ApiConfig.debugLogs]=true,此处改用 [ProductionFilter] 才可见 debug/info。
|
||||
/// release 且 debugLogs=false 时仍不输出(warning 也会被 filter 掉,与原先行为一致)。
|
||||
///
|
||||
/// 使用示例:
|
||||
/// final _log = AppLogger('GenerateVideo');
|
||||
@ -19,6 +22,9 @@ class AppLogger {
|
||||
|
||||
static Logger get _instance {
|
||||
_logger ??= Logger(
|
||||
filter: (!kDebugMode && ApiConfig.debugLogs)
|
||||
? ProductionFilter()
|
||||
: DevelopmentFilter(),
|
||||
printer: PrettyPrinter(
|
||||
methodCount: 0,
|
||||
errorMethodCount: 6,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user