enum Level { all(0), @Deprecated('[verbose] is being deprecated in favor of [trace].') verbose(999), trace(1000), debug(2000), info(3000), warning(4000), error(5000), @Deprecated('[wtf] is being deprecated in favor of [fatal].') wtf(5999), fatal(6000), @Deprecated('[nothing] is being deprecated in favor of [off].') nothing(9999), off(10000), ;
finalint value;
const Level(this.value); }
打印到文件
1 2 3 4 5 6 7 8 9 10
/// 使用 getApplicationDocumentsDirectory 需要 /// 添加 path_provider /// flutter pub add path_provider /// flutter pub ge /// -`NSDocumentDirectory` on iOS and macOS. /// - The Flutter engine's `PathUtils.getDataDirectory` API on Android. Directory documentDir = await getApplicationDocumentsDirectory(); var logger = Logger( output: FileOutput(file: File("${documentDir.path}/log.txt")), );
var logger = Logger( filter: null, // Use the default LogFilter (-> only log in debug mode) printer: PrettyPrinter(dateTimeFormat: DateTimeFormat.dateAndTime), output: MultiOutput(multiOutput), );