import 'dart:developer'; //(auto import will do this even)
//example for api logging
log("${response?.statusCode} : ${response?.request?.path}",
name: "Response", error: response.data);
I (“ Home Page”,标签: “ User Logging”) ;//Info 消息和标识符 TAG
例子:
输入
AppLog.v("-----------------------------");
AppLog.d("I am Debug Log With Default TAG");
AppLog.i("I am Info Log With Default TAG");
AppLog.w("I am Warn Log With Default TAG");
AppLog.e("I am Error Log With Default TAG");
AppLog.wtf("I am Failure Log With Default TAG");
AppLog.v("I am Verbose Log With Default TAG");
//With TAGS
AppLog.v("-----------------------------");
AppLog.d("I am Debug Log With Custom TAG", tag: "Awesome Widget");
AppLog.i("I am Info Log With Custom TAG", tag: "Awesome Widget");
AppLog.w("I am Warn Log With Custom TAG", tag: "Awesome Widget");
AppLog.e("I am Error Log With Custom TAG", tag: "Awesome Widget");
AppLog.wtf("I am Failure Log With Custom TAG", tag: "Awesome Widget");
AppLog.v("I am Verbose Log With Custom TAG", tag: "Awesome Widget");
AppLog.v("-----------------------------");
产出:
Restarted application in 347ms.
FlutterApp: -----------------------------
DEBUG|FlutterApp: I am Debug Log With Default TAG
INFOⓘ|FlutterApp: I am Info Log With Default TAG
WARN⚠️|FlutterApp: I am Warn Log With Default TAG
ERROR⚠️|️FlutterApp: I am Error Log With Default TAG
WTF¯\_(ツ)_/¯|FlutterApp: I am Failure Log With Default TAG
FlutterApp: I am Verbose Log With Default TAG
FlutterApp: -----------------------------
DEBUG|Awesome Widget: I am Debug Log With Custom TAG
INFOⓘ|Awesome Widget: I am Info Log With Custom TAG
WARN⚠️|Awesome Widget: I am Warn Log With Custom TAG
ERROR⚠️|️Awesome Widget: I am Error Log With Custom TAG
WTF¯\_(ツ)_/¯|Awesome Widget: I am Failure Log With Custom TAG
Awesome Widget: I am Verbose Log With Custom TAG
FlutterApp: -----------------------------
还可以为日志级别设置筛选器
将隐藏 log.setLogLevel (log _ 丁优先级) ;//log 以下的日志
优先顺序永远是:
VERBOSE < = log _ 堆优先级 < = FAILURE
优先级: 冗长 < DEBUG < INFO < 警告 < 错误 < 失败
例子
隐藏所有信息和调试日志:
AppLog.setLogLevel(AppLog.WARN);
AppLog.v("-----------------------------");
AppLog.d("Debug Log Will not be Visible");
AppLog.i("Info Log Will not be Visible");
AppLog.w("Warn Log Will be Visible");
AppLog.e("Error Log Will be Visible");
AppLog.wtf("Failure Log Will be Visible");
AppLog.v("Verbose Log Will not be Visible");
AppLog.v("-----------------------------");
输出
WARN⚠️|FlutterApp: Warn Log Will be Visible
ERROR⚠️|️FlutterApp: Error Log Will be Visible
WTF¯\_(ツ)_/¯|FlutterApp: Failure Log Will be Visible