语言: 英语 | 中文简体

flutter_logger

  • 简单、美观且强大的 flutter 日志记录器,它具有日志级别、文件名和行号,并且可以自定义日志级别的颜色,它受到 logger 的启发
    ,iOS 上不支持颜色。
  • 它可以在手机上打印,并且日志可以过滤

下载

flutter_easylogger: ^{LAST_VERSION}

用法

Logger.d("hello");

输出

选项

无标签

Logger.v("hello world");
Logger.d("hello world");
Logger.i("hello world");
Logger.w("hello world");
Logger.e("hello world");
var json = "{\"name\":\"tom\",\"age\":\"18\"}";
Logger.json(json);

带标签

Logger.e("hello",tag:"TAG");

JSON 支持(输出将为调试级别)

Logger.json(json);

跳转到打印文件详情页

高级

Logger.init(
    true,// isEnable ,if production ,please false
    isShowFile: true, // In the IDE, whether the file name is displayed
    isShowTime: true, // In the IDE, whether the time is displayed
    isShowNavigation: true, // In the IDE, When clicked, it jumps to the printed file details page
    levelVerbose: 247, // In the IDE, Set the color
    levelDebug: 26,
    levelInfo: 28,
    levelWarn: 3,
    levelError: 9,
    phoneVerbose: Colors.white54, // In your phone or web,, Set the color
    phoneDebug: Colors.blue,
    phoneInfo: Colors.green,
    phoneWarn: Colors.yellow,
    phoneError: Colors.redAccent,
  );

您可以更改级别的颜色,值在 0-255 之间。请参阅下图了解详情

在手机上打印

日志可以打印在手机上,也可以按日志级别或关键字过滤

// add Overlay
ConsoleOverlay.show(context);
// remoove
ConsoleOverlay.remove();

注意

在生产环境中关闭日志记录

Logger.init(false);
iOS iOS Android Web
IDE 颜色 no
手机颜色

GitHub

https://github.com/niezhiyang/flutter_logger