英语 | 中文

proste_logger

一个简单易用的插件,用于打印长文本并格式化Map或List数据结构。您还可以自定义打印区域的标题信息、文本颜色等。打印内容还显示触发区域和触发方法。

用法

这是一个简单的日志记录方式,您需要初始化一个ProsteLogger,然后调用其内部方法来打印相关内容。

当然,我们可以在初始化时进行一些配置,稍后我会更详细地介绍。

  final logger = ProsteLogger();

  logger.i('this is info msg');

演示

纯文本

简单的Map和List

需要注意的是,如果数据结构中包含类数据结构,打印的数据将不会有双引号。它会先调用jsonEncode()进行格式化,如果失败则调用toString()

格式化Map和List

长文本内容

长文本包含在Map和List中

调用

  final logger = ProsteLogger();

  logger.d('this is debug msg'); // Print only in debug, depending on the constant kDebugMode built into flutter
  logger.i('this is info msg', {title: 'self title', format: false}); // Print methods can also define their own title information or whether to format data
  logger.w('this is warning msg');
  logger.e('this is error msg');

初始化

final logger = ProsteLogger(
  basic: const BasicConfig(
    title: 'config', // printed title
    limitLength: 100, // length of one line
    format: false, // Whether to print after formatting when the data is Map or List
  ),
  colors: const ColorConfig(
    debug: Colors.white, // logger.d() text color
    info: Colors.pink, // logger.i() text color
    warning: Colors.green, // logger.w() text color
    error: Colors.yellow, // logger.e() text color
  ),
);

使用过程中如有任何建议或疑问,欢迎到issues提出,我看到后会尽快处理。谢谢!

GitHub

https://github.com/xyhxx/proste_logger